﻿using NPOI.SS.Formula.Functions;
using SRB.Tg.Common;
using SRB.Tg.DrawingStandard;
using SRB.Tg.Operate;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using Teigha.DatabaseServices;
using Teigha.DatabaseServices.Filters;
using Teigha.Geometry;
using static System.Net.WebRequestMethods;

namespace SRB.Tg.Model
{
    public class DrawingPierStructure
    {
        private List<PierPara> pierList = new List<PierPara>();
        private List<PileRebarPara> pileRebarList = new List<PileRebarPara>();
        private List<PileCapRebarPara> pileCapRebarList = new List<PileCapRebarPara>();
        private List<PierBeamRebarPara> beamRebarList = new List<PierBeamRebarPara>();
        private List<PierRebarPara> pierRebarList = new List<PierRebarPara>();
        private List<PileRebarPara> AbutmentpileRebarList = new List<PileRebarPara>();
        System.Data.DataTable dtBridge = new System.Data.DataTable();
        System.Data.DataTable dtPDis = new System.Data.DataTable();
        System.Data.DataTable dtPileDis = new System.Data.DataTable();
        System.Data.DataTable dtPileCapDis = new System.Data.DataTable();
        System.Data.DataTable dtPierRebarDis = new System.Data.DataTable();
        PierSubstructureType sub_type = PierSubstructureType.Pier;
        System.Data.DataTable dtProject = new System.Data.DataTable();
        System.Data.DataTable dtPileCapRebar = new System.Data.DataTable();//承台钢筋表
        System.Data.DataTable dtPierBeamRebar = new System.Data.DataTable();//盖梁钢筋表
        System.Data.DataRow[] drPileRebar;
        System.Data.DataTable dtProjectConfig = new System.Data.DataTable();
        DrawingConfigModel drawingConfigModel = new DrawingConfigModel();
        string maninid = "";
        string _bridgeId = "";
        bool isExistCap = true;
        int project_type = 0;
        public DrawingPierStructure(string bridgeId, PierSubstructureType type, out System.Data.DataTable dtProjectTb, bool cadFlag = false, bool isMerge = false)
        {
            _bridgeId = bridgeId;
            if (cadFlag)
            {
                string pierParaFile = bridgeId;
                sub_type = type;
                #region  参数数据初始化
                dtProject = new System.Data.DataTable();//项目信息表
                System.Data.DataTable dtP = new System.Data.DataTable(); //墩柱表

                System.Data.DataTable dtBeam = new System.Data.DataTable();//盖梁表
                System.Data.DataTable dtColumn = new System.Data.DataTable();//墩身表
                System.Data.DataTable dtPileCap = new System.Data.DataTable();//承台表
                System.Data.DataTable dtPile = new System.Data.DataTable();//桩基表
                System.Data.DataTable dtPileRebar = new System.Data.DataTable();//桩基钢筋表
                dtPileCapRebar = new System.Data.DataTable();//承台钢筋表
                System.Data.DataTable dtPierRebar = new System.Data.DataTable();//墩身钢筋表
                dtPierBeamRebar = new System.Data.DataTable();//盖梁钢筋表

                System.IO.FileInfo file = new System.IO.FileInfo(pierParaFile);
                #region 项目信息表
                if (file.Extension.Contains("xlsx"))
                    dtProject = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "项目信息");
                else
                    dtProject = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "项目信息");
                #endregion

                foreach (DataRow row in dtProject.Rows)
                {
                    // 打印每一行的数据到控制台
                    foreach (var item in row.ItemArray)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine(); // 换行
                }

                #region 墩柱构造图

                if (file.Extension.Contains("xlsx"))
                    dtP = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "墩柱", 1);
                else
                    dtP = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "墩柱", 1);

                if (file.Extension.Contains("xlsx"))
                    dtBeam = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "盖梁", 1);
                else
                    dtBeam = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "盖梁", 1);

                if (file.Extension.Contains("xlsx"))
                    dtColumn = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "墩身", 1);
                else
                    dtColumn = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "墩身", 1);

                if (file.Extension.Contains("xlsx"))
                    dtPileCap = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "承台", 1);
                else
                    dtPileCap = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "承台", 1);

                if (file.Extension.Contains("xlsx"))
                    dtPile = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "桩基", 1);
                else
                    dtPile = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "桩基", 1);

                if (file.Extension.Contains("xlsx"))
                    dtPierRebar = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "墩身钢筋", 2);
                else
                    dtPierRebar = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "墩身钢筋", 2);

                if (file.Extension.Contains("xlsx"))
                    dtPierBeamRebar = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "盖梁钢筋", 2);
                else
                    dtPierBeamRebar = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "盖梁钢筋", 2);

                DataView dv0 = dtP.DefaultView;
                dtPDis = dv0.ToTable(true, new string[] { "PierNo" });
                if (dtP.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtP.Rows)
                    {
                        PierPara para = new PierPara();
                        para = DataTable2Model.FillModel<PierPara>(dr);
                        if (dtBeam.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsB = dtBeam.Select("BeamNo='" + dr["BeamNo"].ToString() + "'");
                            if (drsB.Length > 0)
                            {
                                busi_beam_structural beamPara = DataTable2Model.FillModel<busi_beam_structural>(drsB[0]);
                                para.beam = beamPara;
                            }
                        }
                        if (dtColumn.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsC = dtColumn.Select("ColumnNo='" + dr["ColumnNo"].ToString() + "'");
                            if (drsC.Length > 0)
                            {
                                busi_pier_body_structural columnPara = DataTable2Model.FillModel<busi_pier_body_structural>(drsC[0]);
                                para.column = columnPara;
                            }
                        }
                        if (dtPileCap.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsPileCap = dtPileCap.Select("PileCapNo='" + dr["PileCapNo"].ToString() + "'");
                            if (drsPileCap.Length > 0)
                            {
                                busi_pile_cap_structural pileCapPara = DataTable2Model.FillModel<busi_pile_cap_structural>(drsPileCap[0]);
                                para.pileCap = pileCapPara;
                            }
                        }
                        if (dtPile.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsP = dtPile.Select("PileNo='" + dr["PileNo"].ToString() + "'");
                            if (drsP.Length > 0)
                            {
                                busi_pile_structural pilePara = DataTable2Model.FillModel<busi_pile_structural>(drsP[0]);
                                para.pile = pilePara;
                            }
                        }

                        #region 墩身钢筋
                        if (dtPierRebar.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsPier = dtPierRebar.Select("id='" + dr["PierRebarID"].ToString() + "'");
                            if (drsPier.Length > 0)
                            {
                                PierRebarPara pierRebarPara = DataTable2Model.FillModel<PierRebarPara>(drsPier[0]);
                                para.pierRebar = pierRebarPara;
                            }
                        }

                        #endregion

                        #region 盖梁钢筋
                        if (dtPierBeamRebar.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsBeamRebar = dtPierBeamRebar.Select("id='" + dr["PierBeamRebarID"].ToString() + "'");
                            if (drsBeamRebar.Length > 0)
                            {
                                PierBeamRebarPara pierBeamRebarPara = DataTable2Model.FillModel<PierBeamRebarPara>(drsBeamRebar[0]);
                                para.beamRebar = pierBeamRebarPara;

                                //beamRebarList.Add(pierBeamRebarPara);
                            }
                        }

                        #endregion
                        pierList.Add(para);
                    }
                }
                #endregion

                #region 桩基钢筋



                if (file.Extension.Contains("xlsx"))
                    dtPileRebar = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "桩基钢筋", 2);
                else
                    dtPileRebar = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "桩基钢筋", 2);
                DataView dvPile = dtPileRebar.DefaultView;
                dtPileDis = dvPile.ToTable(true, new string[] { "configure_name" });

                if (dtPileRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtPileRebar.Rows)
                    {
                        //PileRebarPara para = new PileRebarPara();
                        PileRebarPara para = DataTable2Model.FillModel<PileRebarPara>(dr);
                        pileRebarList.Add(para);
                    }
                }

                #endregion

                #region 承台钢筋



                if (file.Extension.Contains("xlsx"))
                    dtPileCapRebar = new ExcelHelper().ExcelToTableForXLSXBySheetName(pierParaFile, "承台钢筋", 2);
                else
                    dtPileCapRebar = new ExcelHelper().ExcelToTableForXLSBySheetName(pierParaFile, "承台钢筋", 2);
                DataView dvPileCap = dtPileCapRebar.DefaultView;
                dtPileCapDis = dvPileCap.ToTable(true, new string[] { "configure_name" });

                if (dtPileCapRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtPileCapRebar.Rows)
                    {
                        PileCapRebarPara para = DataTable2Model.FillModel<PileCapRebarPara>(dr);
                        pileCapRebarList.Add(para);
                    }
                }


                if (dtPileCapRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtPierBeamRebar.Rows)
                    {
                        PierBeamRebarPara pierBeamRebarPara = DataTable2Model.FillModel<PierBeamRebarPara>(dr);

                        beamRebarList.Add(pierBeamRebarPara);
                    }
                }
                #endregion

                #endregion
            }
            else
            {
                sub_type = type;
                #region  参数数据初始化   逻辑混乱，需要重写
                dtProject = new System.Data.DataTable();//项目信息表
                System.Data.DataTable dtBridgeDrawing = new System.Data.DataTable();
                System.Data.DataTable dtA = new System.Data.DataTable(); //墩柱表
                System.Data.DataTable dtP = new System.Data.DataTable(); //墩柱表
                System.Data.DataTable dtBeam = new System.Data.DataTable();//盖梁表
                System.Data.DataTable dtColumn = new System.Data.DataTable();//墩身表
                System.Data.DataTable dtPileCap = new System.Data.DataTable();//承台表
                System.Data.DataTable dtPile = new System.Data.DataTable();//桩基表
                System.Data.DataTable dtPileRebar = new System.Data.DataTable();//桩基钢筋表
                dtPileCapRebar = new System.Data.DataTable();//承台钢筋表
                System.Data.DataTable dtPierRebar = new System.Data.DataTable();//墩身钢筋表
                dtPierBeamRebar = new System.Data.DataTable();//盖梁钢筋表
                System.Data.DataTable dtAbutmentPileRebar = new System.Data.DataTable();//桥台桩基钢筋表

                int bridge_scope = 1;//桥幅（单幅桥和双幅桥）
                string sqlBridge = "select * from busi_bridge where id='" + bridgeId + "'";
                dtBridge = MySqlHelper.ExecuteDataTable(sqlBridge, CommandType.Text);
               
                if (dtBridge.Rows.Count > 0)
                {
                    maninid = dtBridge.Rows[0]["main_id"].ToString();
                  
                    sqlBridge = "select * from busi_bridge_main where id='" + maninid + "'";
                    dtBridge = MySqlHelper.ExecuteDataTable(sqlBridge, CommandType.Text);
                    if (dtBridge.Rows.Count > 0)
                    {
                        string sqlProject = "select *from  busi_project where  id='" + dtBridge.Rows[0]["project_id"].ToString() + "'";
                        System.Data.DataTable dtProject1 = MySqlHelper.ExecuteDataTable(sqlProject, CommandType.Text);
                        if(dtProject1.Rows.Count>0)
                        {
                            project_type =int.Parse( dtProject1.Rows[0]["project_type"].ToString());
                        }
                        bridge_scope = int.Parse(dtBridge.Rows[0]["bridge_scope"].ToString());
                        if (bridge_scope > 0)
                        {
                            isMerge = dtBridge.Rows[0]["drawing_level"].ToString() == "1" ? true : false; //双幅桥图纸是否合并
                        }
                        if (isMerge)
                        {
                            string sqlDrawing = "select *  from busi_bridge_catalog where  bridge_main_id='" + maninid + "'";
                            dtProject = MySqlHelper.ExecuteDataTable(sqlDrawing, CommandType.Text);

                            string sqlPier = "select * from vi_pier_structural where  bridge_main_id='" + maninid + "' and span_type = 'P'  ORDER BY name,Location desc";
                            dtP = MySqlHelper.ExecuteDataTable(sqlPier, CommandType.Text);

                            string sqlA = "select * from vi_pier_structural where  bridge_main_id='" + maninid + "' and span_type = 'A' ORDER BY name,Location desc";
                            dtA = MySqlHelper.ExecuteDataTable(sqlA, CommandType.Text);

                            string sqlBeam = "SELECT *  FROM busi_beam_structural where id in (select  beam_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ) ";
                            dtBeam = MySqlHelper.ExecuteDataTable(sqlBeam, CommandType.Text);

                            string sqlColumn = "SELECT *  FROM busi_pier_body_structural where id in (select  pier_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ) ";
                            dtColumn = MySqlHelper.ExecuteDataTable(sqlColumn, CommandType.Text);

                            string sqlPileCap = "SELECT *  FROM busi_pile_cap_structural where id in (select  pile_cap_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ) ";
                            dtPileCap = MySqlHelper.ExecuteDataTable(sqlPileCap, CommandType.Text);

                            string sqlPile = "SELECT *  FROM busi_pile_structural where id in (select  pile_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ) ";
                            dtPile = MySqlHelper.ExecuteDataTable(sqlPile, CommandType.Text);

                            string sqlBeamRebar = "select * from busi_beam_steel where id in (" +
                                "select  beam_steel_id from busi_beam_structural where id in (select  beam_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ) " +
                                ") ";
                            dtPierBeamRebar = MySqlHelper.ExecuteDataTable(sqlBeamRebar, CommandType.Text);

                            string sqlPierRebar = "select * from busi_pier_body_steel where id in (" +
                                "select  pier_body_steel_id from busi_pier_body_structural where id in (select  pier_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' )" +
                                ") ";
                            dtPierRebar = MySqlHelper.ExecuteDataTable(sqlPierRebar, CommandType.Text);

                            //string sqlPileCapRebar = "select * from (select * from busi_pile_cap_steel where id in (select  pile_cap_steel_id from vi_pier_structural where  bridge_main_id='" + maninid + "'and span_type = 'P' )) a left join (select vps.pile_cap_tructural_id,vps.pile_cap_steel_id,vps.pile_structural_id,pcs.cushion_thickness,pcs.cushion_cornice_length,ps.dia as pile_diameter,ps.span_w,ps.span_l from vi_pier_structural vps left join busi_pile_structural ps on vps.pile_structural_id = ps.id  left join busi_pile_cap_structural pcs  on vps.pile_cap_tructural_id = pcs.id  where  vps.bridge_main_id='" + maninid + "') b on a.id = b.pile_cap_steel_id GROUP BY id";
                            string sqlPileCapRebar = "select * from (select * from busi_pile_cap_steel where id in (" +
                                "select  pile_cap_steel_id from busi_pile_cap_structural where id in (select  pile_cap_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' ))) " +
                                "a left join (select vps.pile_cap_structural_id,pcs.pile_cap_steel_id,vps.pile_structural_id,pcs.cushion_thickness,pcs.cushion_cornice_length,ps.dia as pile_diameter,bps.span_w as span_l,bps.span_l as span_w from vi_pier_structural vps left join busi_pile_structural ps on vps.pile_structural_id = ps.id  left join busi_pile_cap_structural pcs  on vps.pile_cap_structural_id = pcs.id  left join busi_pier_structural bps on vps.structural_id = bps.id where  vps.bridge_main_id='" + maninid + "') b on a.id = b.pile_cap_steel_id GROUP BY id";
                            dtPileCapRebar = MySqlHelper.ExecuteDataTable(sqlPileCapRebar, CommandType.Text);

                            //string sqlPileRebar = "select * from(select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (select  pile_steel_id from vi_pier_structural where  bridge_main_id='" + maninid + "'and span_type = 'P' )) a left join (select vps.pier_body_steel_id,vps.pile_steel_id,pbs.middle_encryption_length from vi_pier_structural vps left join busi_pier_body_steel pbs  on vps.pier_body_steel_id = pbs.id  where  bridge_main_id='" + maninid + "') b on a.id = b.pile_steel_id GROUP BY id ";
                            string sqlPileRebar = "select * from(select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (" +
                                "select  pile_steel_id from busi_pile_structural where id in (select  pile_structural_id from vi_pier_structural where  bridge_main_id ='" + maninid + "'and span_type = 'P' )))" +
                                " a left join (select pbsl.pier_body_steel_id,pss.pile_steel_id,pbs.middle_encryption_length from vi_pier_structural vps left join busi_pier_body_structural pbsl on pbsl.id=vps.pier_structural_id  left join busi_pier_body_steel pbs  on pbsl.pier_body_steel_id = pbs.id  left join busi_pile_structural pss on pss.id=vps.pile_structural_id where  bridge_main_id='" + maninid + "') b on a.id = b.pile_steel_id GROUP BY id ";

                            dtPileRebar = MySqlHelper.ExecuteDataTable(sqlPileRebar, CommandType.Text);

                            //string sqlAbutmentPileRebar = "select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (select  abutment_pile_steel_id from vi_pier_structural where  bridge_main_id='" + maninid + "'and span_type = 'A')";
                            string sqlAbutmentPileRebar = "select DISTINCT bps.id , bps.configure_name , vps.abutment_pile_height as pile_length, bps.pile_diameter , bps.pile_penetration_depth , bps.concrete_no , bps.concrete_protect_layer AS pier_protect_layer, bps.main_reinforcement_grade , bps.reinforcement_grade , bps.bottom_distance , bps.top_size , bps.bottom_size , bps.main_reinforcement_diameter , bps.main_reinforcement_number , bps.spiral_reinforcement_diameter , bps.top_encryption_length , bps.top_encryption_spacing , bps.middle_encryption_spacing , bps.bottom_encryption_length , bps.bottom_encryption_spacing , bps.outer_strengthen_reinforcement_diameter , bps.outer_strengthen_reinforcement_spacing , bps.inner_strengthen_reinforcement_diameter , bps.inner_strengthen_reinforcement_num , bps.top_reinforcement_diameter , bps.top_reinforcement_number , bps.acoustic_tube_number , bps.acoustic_tube_type , bps.acoustic_tube_length , (case bps.is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , bps.out_length , bps.pile_type , bps.Depth , bps.status , bps.create_time , bps.update_time , bps.create_by , bps.update_by , bps.sys_org_code from busi_pile_steel as bps left join vi_pier_structural vps on bps.id = vps.abutment_pile_steel_id where vps.bridge_main_id='" + maninid + "'and vps.span_type = 'A'";
                            dtAbutmentPileRebar = MySqlHelper.ExecuteDataTable(sqlAbutmentPileRebar, CommandType.Text);
                        }
                        else
                        {
                            string sqlDrawing = "select *  from busi_bridge_catalog where  bridge_id='" + bridgeId + "'";
                            dtProject = MySqlHelper.ExecuteDataTable(sqlDrawing, CommandType.Text);

                            string sqlPier = "select * from vi_pier_structural where  bridge_id='" + bridgeId + "' and span_type = 'P'  ORDER BY name,Location desc";
                            dtP = MySqlHelper.ExecuteDataTable(sqlPier, CommandType.Text);

                            string sqlA = "select * from vi_pier_structural where  bridge_id='" + bridgeId + "' and span_type = 'A' ORDER BY name,Location desc";
                            dtA = MySqlHelper.ExecuteDataTable(sqlA, CommandType.Text);

                            string sqlBeam = "SELECT *  FROM busi_beam_structural where id in (select  beam_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ) ";
                            dtBeam = MySqlHelper.ExecuteDataTable(sqlBeam, CommandType.Text);

                            string sqlColumn = "SELECT *  FROM busi_pier_body_structural where id in (select  pier_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ) ";
                            dtColumn = MySqlHelper.ExecuteDataTable(sqlColumn, CommandType.Text);

                            string sqlPileCap = "SELECT *  FROM busi_pile_cap_structural where id in (select  pile_cap_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ) ";
                            dtPileCap = MySqlHelper.ExecuteDataTable(sqlPileCap, CommandType.Text);

                            string sqlPile = "SELECT *  FROM busi_pile_structural where id in (select  pile_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ) ";
                            dtPile = MySqlHelper.ExecuteDataTable(sqlPile, CommandType.Text);

                            string sqlBeamRebar = "select * from busi_beam_steel where id in (" +
                                "select  beam_steel_id from busi_beam_structural where id in (select  beam_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ) " +
                                ") ";
                            dtPierBeamRebar = MySqlHelper.ExecuteDataTable(sqlBeamRebar, CommandType.Text);

                            string sqlPierRebar = "select * from busi_pier_body_steel where id in (" +
                                "select  pier_body_steel_id from busi_pier_body_structural where id in (select  pier_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' )" +
                                ") ";
                            dtPierRebar = MySqlHelper.ExecuteDataTable(sqlPierRebar, CommandType.Text);

                            //string sqlPileCapRebar = "select * from (select * from busi_pile_cap_steel where id in (select  pile_cap_steel_id from vi_pier_structural where  bridge_id='" + bridgeId + "'and span_type = 'P' )) a left join (select vps.pile_cap_tructural_id,vps.pile_cap_steel_id,vps.pile_structural_id,pcs.cushion_thickness,pcs.cushion_cornice_length,ps.dia as pile_diameter,ps.span_w,ps.span_l from vi_pier_structural vps left join busi_pile_structural ps on vps.pile_structural_id = ps.id  left join busi_pile_cap_structural pcs  on vps.pile_cap_tructural_id = pcs.id  where  vps.bridge_id='" + bridgeId + "') b on a.id = b.pile_cap_steel_id GROUP BY id";
                            string sqlPileCapRebar = "select * from (select * from busi_pile_cap_steel where id in (" +
                                "select  pile_cap_steel_id from busi_pile_cap_structural where id in (select  pile_cap_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' ))) " +
                                "a left join (select vps.pile_cap_structural_id,pcs.pile_cap_steel_id,vps.pile_structural_id,pcs.cushion_thickness,pcs.cushion_cornice_length,ps.dia as pile_diameter,bps.span_w as span_l,bps.span_l as span_w from vi_pier_structural vps left join busi_pile_structural ps on vps.pile_structural_id = ps.id  left join busi_pile_cap_structural pcs  on vps.pile_cap_structural_id = pcs.id  left join busi_pier_structural bps on vps.structural_id = bps.id where  vps.bridge_id='" + bridgeId + "') b on a.id = b.pile_cap_steel_id GROUP BY id";
                            dtPileCapRebar = MySqlHelper.ExecuteDataTable(sqlPileCapRebar, CommandType.Text);

                            //string sqlPileRebar = "select * from(select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (select  pile_steel_id from vi_pier_structural where  bridge_id='" + bridgeId + "'and span_type = 'P' )) a left join (select vps.pier_body_steel_id,vps.pile_steel_id,pbs.middle_encryption_length from vi_pier_structural vps left join busi_pier_body_steel pbs  on vps.pier_body_steel_id = pbs.id  where  bridge_id='" + bridgeId + "') b on a.id = b.pile_steel_id GROUP BY id ";
                            string sqlPileRebar = "select * from(select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (" +
                                "select  pile_steel_id from busi_pile_structural where id in (select  pile_structural_id from vi_pier_structural where  bridge_id ='" + bridgeId + "'and span_type = 'P' )))" +
                                " a left join (select pbsl.pier_body_steel_id,pss.pile_steel_id,pbs.middle_encryption_length from vi_pier_structural vps left join busi_pier_body_structural pbsl on pbsl.id=vps.pier_structural_id  left join busi_pier_body_steel pbs  on pbsl.pier_body_steel_id = pbs.id  left join busi_pile_structural pss on pss.id=vps.pile_structural_id where  bridge_id='" + bridgeId + "') b on a.id = b.pile_steel_id GROUP BY id ";

                            dtPileRebar = MySqlHelper.ExecuteDataTable(sqlPileRebar, CommandType.Text);

                            //string sqlAbutmentPileRebar = "select id , configure_name , pile_length , pile_diameter , pile_penetration_depth , concrete_no , concrete_protect_layer AS pier_protect_layer, main_reinforcement_grade , reinforcement_grade , bottom_distance , top_size , bottom_size , main_reinforcement_diameter , main_reinforcement_number , spiral_reinforcement_diameter , top_encryption_length , top_encryption_spacing , middle_encryption_spacing , bottom_encryption_length , bottom_encryption_spacing , outer_strengthen_reinforcement_diameter , outer_strengthen_reinforcement_spacing , inner_strengthen_reinforcement_diameter , inner_strengthen_reinforcement_num , top_reinforcement_diameter , top_reinforcement_number , acoustic_tube_number , acoustic_tube_type , acoustic_tube_length , (case is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , out_length , pile_type , Depth , status , create_time , update_time , create_by , update_by , sys_org_code from busi_pile_steel where id in (select  abutment_pile_steel_id from vi_pier_structural where  bridge_id='" + bridgeId + "'and span_type = 'A')";
                            string sqlAbutmentPileRebar = "select DISTINCT bps.id , bps.configure_name , vps.abutment_pile_height as pile_length, bps.pile_diameter , bps.pile_penetration_depth , bps.concrete_no , bps.concrete_protect_layer AS pier_protect_layer, bps.main_reinforcement_grade , bps.reinforcement_grade , bps.bottom_distance , bps.top_size , bps.bottom_size , bps.main_reinforcement_diameter , bps.main_reinforcement_number , bps.spiral_reinforcement_diameter , bps.top_encryption_length , bps.top_encryption_spacing , bps.middle_encryption_spacing , bps.bottom_encryption_length , bps.bottom_encryption_spacing , bps.outer_strengthen_reinforcement_diameter , bps.outer_strengthen_reinforcement_spacing , bps.inner_strengthen_reinforcement_diameter , bps.inner_strengthen_reinforcement_num , bps.top_reinforcement_diameter , bps.top_reinforcement_number , bps.acoustic_tube_number , bps.acoustic_tube_type , bps.acoustic_tube_length , (case bps.is_out_double_layout when 0 then 'FALSE' else 'TRUE' end) AS is_out_double_layout , bps.out_length , bps.pile_type , bps.Depth , bps.status , bps.create_time , bps.update_time , bps.create_by , bps.update_by , bps.sys_org_code from busi_pile_steel as bps left join vi_pier_structural vps on bps.id = vps.abutment_pile_steel_id where vps.bridge_id='" + bridgeId + "'and vps.span_type = 'A'";
                            dtAbutmentPileRebar = MySqlHelper.ExecuteDataTable(sqlAbutmentPileRebar, CommandType.Text);

                        }
                    }
                }

                DataView dv0 = dtP.DefaultView;
                dtPDis = dv0.ToTable(true, new string[] { "name" });
                if (dtP.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtP.Rows)
                    {
                        PierPara para = new PierPara();
                        para = DataTable2Model.FillModel<PierPara>(dr);
                        if (dtBeam.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsB = dtBeam.Select("id='" + dr["beam_structural_id"].ToString() + "'");
                            if (drsB.Length > 0)
                            {
                                busi_beam_structural beamPara = DataTable2Model.FillModel<busi_beam_structural>(drsB[0]);
                                para.beam = beamPara;
                            }
                        }
                        if (dtColumn.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsC = dtColumn.Select("id='" + dr["pier_structural_id"].ToString() + "'");
                            if (drsC.Length > 0)
                            {
                                busi_pier_body_structural columnPara = DataTable2Model.FillModel<busi_pier_body_structural>(drsC[0]);
                                para.column = columnPara;
                            }
                        }
                        if (dtPileCap.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsPileCap = dtPileCap.Select("id='" + dr["pile_cap_structural_id"].ToString() + "'");
                            if (drsPileCap.Length > 0)
                            {
                                busi_pile_cap_structural pileCapPara = DataTable2Model.FillModel<busi_pile_cap_structural>(drsPileCap[0]);
                                para.pileCap = pileCapPara;
                            }
                        }
                        if (dtPile.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsP = dtPile.Select("id='" + dr["pile_structural_id"].ToString() + "'");
                            if (drsP.Length > 0)
                            {
                                busi_pile_structural pilePara = DataTable2Model.FillModel<busi_pile_structural>(drsP[0]);
                                string sqlPierStructural = "SELECT *  FROM busi_pier_structural where id  ='" + dr["structural_id"].ToString() +"'";
                                System.Data.DataTable dtPierStructural = MySqlHelper.ExecuteDataTable(sqlPierStructural, CommandType.Text);
                                pilePara.span_w = dtPierStructural.Rows[0]["span_w"].ToString();
                                pilePara.span_l = dtPierStructural.Rows[0]["span_l"].ToString();
                                para.pile = pilePara;
                            }
                        }

                        #region 墩身钢筋
                        if (dtPierRebar.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsPier = dtPierRebar.Select("id='" + dr["pier_body_steel_id"].ToString() + "'");
                            if (drsPier.Length > 0)
                            {
                                PierRebarPara pierRebarPara = DataTable2Model.FillModel<PierRebarPara>(drsPier[0]);
                                //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                                string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                                pierRebarPara.concrete_no = FinddictItem(sqlfindconcrete_no, pierRebarPara.concrete_no);
                                //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                                string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                                pierRebarPara.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierRebarPara.main_reinforcement_grade);
                                pierRebarPara.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierRebarPara.reinforcement_grade);
                                para.pierRebar = pierRebarPara;
                            }
                        }

                        #endregion

                        #region 盖梁钢筋
                        if (dtPierBeamRebar.Rows.Count > 0)
                        {
                            System.Data.DataRow[] drsBeamRebar = dtPierBeamRebar.Select("id='" + dr["beam_steel_id"].ToString() + "'");
                            if (drsBeamRebar.Length > 0)
                            {
                                PierBeamRebarPara pierBeamRebarPara = DataTable2Model.FillModel<PierBeamRebarPara>(drsBeamRebar[0]);
                                //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                                string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                                pierBeamRebarPara.concrete_no = FinddictItem(sqlfindconcrete_no, pierBeamRebarPara.concrete_no);
                                //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                                string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                                pierBeamRebarPara.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierBeamRebarPara.main_reinforcement_grade);
                                pierBeamRebarPara.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierBeamRebarPara.reinforcement_grade);

                                int count = dtP.AsEnumerable().Count(row => row.Field<string>("beam_steel_id") == drsBeamRebar[0]["id"].ToString());
                                pierBeamRebarPara.structure_number = count;
                                para.beamRebar = pierBeamRebarPara;

                                //beamRebarList.Add(pierBeamRebarPara);
                            }
                        }

                        #endregion
                        pierList.Add(para);
                    }
                }
                #endregion

                #region 桩基钢筋
                DataView dvPile = dtPileRebar.DefaultView;
                dtPileDis = dvPile.ToTable(true, new string[] { "configure_name" });

                if (dtPileRebar.Rows.Count > 0)
                {
                    if (project_type == 2)
                    {
                        string sqlPile = "select *from ( select bridge_id,pile_steel_id,pile_length,dia,is_add_steel_casing,steel_casing_length,steel_casing_thickness,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names,GROUP_CONCAT(DISTINCT pile_no SEPARATOR '、') AS pile_nos,COUNT(*) as structure_number from vi_portable_steel_bridge_pile "
                         + "WHERE bridge_id ='" + bridgeId + "' GROUP BY pile_length,dia,is_add_steel_casing,steel_casing_length,steel_casing_thickness  )a  order by names asc";
                        System.Data.DataTable dtpileAll = MySqlHelper.ExecuteDataTable(sqlPile, CommandType.Text);
                        for (int i = 0; i < dtpileAll.Rows.Count; i++)
                        {
                            System.Data.DataRow drP = dtpileAll.Rows[i];
                            System.Data.DataRow[] drPs = dtPileRebar.Select("id='" + drP["pile_steel_id"].ToString() + "'");
                            PileRebarPara para = DataTable2Model.FillModel<PileRebarPara>(drPs[0]);
                            para.project_type = project_type;
                            string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                            para.concrete_no = FinddictItem(sqlfindconcrete_no, para.concrete_no);
                            //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                            string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                            para.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.main_reinforcement_grade);
                            para.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.reinforcement_grade);
                            //string sqlfindpile_type = "select * from sys_dict_item where dict_id ='1706592047766376450' ";
                            string sqlfindpile_type = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='pile_type'  ";
                            para.pile_type = FinddictItem(sqlfindpile_type, para.pile_type);
                            para.pile_length = double.Parse(drP["pile_length"].ToString()) * 100;
                            para.pile_diameter = double.Parse(drP["dia"].ToString());
                            para.is_add_steel_casing = drP["is_add_steel_casing"].ToString();
                            para.steel_casing_length = String.IsNullOrEmpty(drP["steel_casing_length"].ToString()) ? 0 : double.Parse(drP["steel_casing_length"].ToString());
                            para.steel_casing_thickness = String.IsNullOrEmpty(drP["steel_casing_thickness"].ToString()) ? 0 : double.Parse(drP["steel_casing_thickness"].ToString());
                            para.structure_number = int.Parse(drP["structure_number"].ToString());
                            para.pier_name = drP["names"].ToString();
                            para.pile_name = drP["pile_nos"].ToString();
                            pileRebarList.Add(para);
                        }
                    }
                    else
                    {
                        foreach (System.Data.DataRow dr in dtPileRebar.Rows)
                        {

                            #region 非机场桥 逻辑有问题后期修改
                            //PileRebarPara para = new PileRebarPara();
                            PileRebarPara para = DataTable2Model.FillModel<PileRebarPara>(dr);
                            para.project_type = project_type;
                            //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                            string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                            para.concrete_no = FinddictItem(sqlfindconcrete_no, para.concrete_no);
                            //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                            string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                            para.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.main_reinforcement_grade);
                            para.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.reinforcement_grade);
                            //string sqlfindpile_type = "select * from sys_dict_item where dict_id ='1706592047766376450' ";
                            string sqlfindpile_type = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='pile_type'  ";
                            para.pile_type = FinddictItem(sqlfindpile_type, para.pile_type);
                            System.Data.DataTable dtpilelengthAll = new System.Data.DataTable();
                            int Pilestructure_number = 0;
                            System.Data.DataRow[] dtprow = dtP.Select("pile_steel_id='" + dr["id"].ToString() + "' and span_type='P'");
                            if (dtprow.Length > 0)
                            {
                                string sqlportable_steel_bridge_pile1 = "SELECT distinct psbp.pile_length,psbp.is_add_steel_casing,psbp.steel_casing_length,psbp.steel_casing_thickness FROM busi_portable_steel_bridge_pile psbp LEFT JOIN busi_portable_steel_bridge_pier psb ON psbp.pier_id = psb.id LEFT JOIN busi_span bs ON psb.span_id = bs.id  WHERE bs.bridge_id ='" + bridgeId + "' AND bs.status=0";
                                dtpilelengthAll = MySqlHelper.ExecuteDataTable(sqlportable_steel_bridge_pile1, CommandType.Text);
                                //判断是否为机场桥桩基钢筋
                                if (dtprow.Any(row => row["id"] is DBNull && row["pile_height"] is DBNull))
                                {
                                    for (int i = 0; i < dtprow.Length; i++)
                                    {
                                        string sqlspanid = "SELECT id FROM busi_span where bridge_id  ='" + bridgeId + "' and name='" + dtprow[i]["name"].ToString() + "' AND status=0 AND span_type='P'";
                                        System.Data.DataTable dtspanId = MySqlHelper.ExecuteDataTable(sqlspanid, CommandType.Text);
                                        string spanid = dtspanId.Rows[0]["id"].ToString();
                                        string sqlportable_steel_bridge_pile = "SELECT psbp.pile_no,psbp.pile_length,psbp.is_add_steel_casing,psbp.steel_casing_length,psbp.steel_casing_thickness FROM busi_portable_steel_bridge_pile psbp LEFT JOIN busi_portable_steel_bridge_pier psb ON psbp.pier_id = psb.id LEFT JOIN busi_span bs ON psb.span_id = bs.id  WHERE bs.id ='" + spanid + "' AND bs.status=0";
                                        System.Data.DataTable dtpilelength = MySqlHelper.ExecuteDataTable(sqlportable_steel_bridge_pile, CommandType.Text);
                                        dtprow[i]["pile_height"] = dtpilelength.Rows[0]["pile_length"].ToString();
                                    }
                                }
                                System.Data.DataRow[] filteredSameRows = dtP.Select("pile_steel_id='" + dr["id"].ToString() + "'" + " and pile_height='" + double.Parse(dr["pile_length"].ToString()) * 0.01 + "'");
                                if (filteredSameRows.Length > 0)
                                {
                                    string pname = "";
                                    for (int i = 0; i < filteredSameRows.Length; i++)
                                    {
                                        string pile_structural_id = filteredSameRows[i]["pile_structural_id"].ToString();
                                        System.Data.DataRow[] drPile = dtPile.Select("id='" + pile_structural_id + "'");
                                        busi_pile_structural pilePara = DataTable2Model.FillModel<busi_pile_structural>(drPile[0]);
                                        string sqlPierStructural = "SELECT *  FROM busi_pier_structural where id  ='" + filteredSameRows[i]["structural_id"].ToString() + "'";
                                        System.Data.DataTable dtPierStructural = MySqlHelper.ExecuteDataTable(sqlPierStructural, CommandType.Text);
                                        pilePara.span_w = dtPierStructural.Rows[0]["span_w"].ToString();
                                        pilePara.span_l = dtPierStructural.Rows[0]["span_l"].ToString();
                                        int Pilenumber = (2 + pilePara.span_w.Count(c => c == '+')) * (2 + pilePara.span_l.Count(c => c == '+'));
                                        Pilestructure_number += Pilenumber;
                                        if (String.IsNullOrWhiteSpace(pname))
                                            pname += filteredSameRows[i]["name"].ToString();
                                        else
                                            pname += "," + filteredSameRows[i]["name"].ToString();


                                    }
                                    para.structure_number = Pilestructure_number;
                                    double para_pile_length = para.pile_length * 0.01;
                                    System.Data.DataTable dtnames = new System.Data.DataTable();
                                    if (isMerge)
                                    {
                                        string sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  pile_steel_id= '" + para.id + "' and  pile_height =  '" + para_pile_length.ToString() + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                                    }
                                    else
                                    {
                                        string sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  pile_steel_id= '" + para.id + "' and  pile_height =  '" + para_pile_length.ToString() + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                                    }
                                    if (dtnames.Rows.Count > 0)
                                    {
                                        para.pier_name = dtnames.Rows[0]["names"].ToString();
                                    }
                                    else
                                    {
                                        para.pier_name = pname;
                                    }
                                    pileRebarList.Add(para);
                                }

                                //判断墩柱中使用此桩基钢筋个数
                                //如果使用多次但桩长不一样，则应该生成多条
                                //如果使用多次且桩长一致，则生成一条
                                //注意单位换算
                                double pile_length = para.pile_length * 0.01;
                                DataRow[] filteredRows = dtprow.Where(row => double.Parse(row["pile_height"].ToString()) != pile_length).ToArray();
                                if (filteredRows.Length > 0)
                                {
                                    for (int i = 0; i < filteredRows.Length; i++)
                                    {
                                        //防止重复添加
                                        string pile_height = filteredRows[i]["pile_height"].ToString();
                                        pile_length = double.Parse(pile_height) * 100;
                                        if (pileRebarList.Any(m => m.pile_length == pile_length))
                                        {
                                            continue;
                                        }
                                        PileRebarPara filteredpara = new PileRebarPara();
                                        Type PileRebarParatype = typeof(PileRebarPara);
                                        PropertyInfo[] properties = PileRebarParatype.GetProperties();
                                        foreach (PropertyInfo property in properties)
                                        {
                                            property.SetValue(filteredpara, property.GetValue(para));
                                        }
                                        filteredpara.pile_length = pile_length;
                                        System.Data.DataTable dtfilterednames = new System.Data.DataTable();
                                        string sqlsteel = "";
                                        //if (dtprow.Any(row => row["id"] is DBNull))
                                        //{
                                        //    if (isMerge)
                                        //    {
                                        //        sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  pile_steel_id= '" + para.id + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        //    }
                                        //    else
                                        //    {
                                        //        sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  pile_steel_id= '" + para.id + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        //    }
                                        //}
                                        //else 
                                        //{
                                        //    if (isMerge)
                                        //    {
                                        //        sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  pile_steel_id= '" + para.id + "' and  pile_height =  '" + pile_height + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        //    }
                                        //    else
                                        //    {
                                        //        sqlsteel = "select pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  pile_steel_id= '" + para.id + "' and  pile_height =  '" + pile_height + "' and span_type = 'P' GROUP BY pile_steel_id";
                                        //    }
                                        //}
                                        DataRow[] drs = dtP.Select("pile_height=" + pile_height + " and pile_steel_id='" + para.id + "'");
                                        string pierName = "";
                                        if (drs.Length > 0)
                                        {
                                            pierName = drs[0]["name"].ToString();
                                            if (drs.Length > 1)
                                                for (int m = 1; m < drs.Length; m++)
                                                {
                                                    pierName += "," + drs[m]["name"].ToString();
                                                }
                                        }
                                        //  dtfilterednames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                                        //判断目标桩长个数
                                        string pile_structural_id = filteredRows[i]["pile_structural_id"].ToString();
                                        System.Data.DataRow[] drPile = dtPile.Select("id='" + pile_structural_id + "'");
                                        busi_pile_structural pilePara = DataTable2Model.FillModel<busi_pile_structural>(drPile[0]);
                                        string sqlPierStructural = "SELECT *  FROM busi_pier_structural where id  ='" + filteredRows[i]["structural_id"].ToString() + "'";
                                        System.Data.DataTable dtPierStructural = MySqlHelper.ExecuteDataTable(sqlPierStructural, CommandType.Text);
                                        pilePara.span_w = dtPierStructural.Rows[0]["span_w"].ToString();
                                        pilePara.span_l = dtPierStructural.Rows[0]["span_l"].ToString();
                                        DataRow drl = dtpilelengthAll.Select("pile_length='" + pile_height + "'")[0];
                                        filteredpara.is_add_steel_casing = drl["is_add_steel_casing"].ToString();
                                        filteredpara.steel_casing_length = String.IsNullOrEmpty(drl["steel_casing_length"].ToString()) ? 0 : double.Parse(drl["steel_casing_length"].ToString());
                                        filteredpara.steel_casing_thickness = String.IsNullOrEmpty(drl["steel_casing_thickness"].ToString()) ? 0 : double.Parse(drl["steel_casing_thickness"].ToString());
                                        int Pilenumber = (2 + pilePara.span_w.Count(c => c == '+')) * (2 + pilePara.span_l.Count(c => c == '+'));
                                        int count = filteredRows.Count(row => Convert.ToDouble(row["pile_height"]) == double.Parse(pile_height));
                                        filteredpara.structure_number = Pilenumber * count;
                                        filteredpara.pier_name = pierName;// dtfilterednames.Rows[0]["names"].ToString();
                                        pileRebarList.Add(filteredpara);
                                        isExistCap = true;
                                    }
                                }

                            }
                            #endregion
                        }
                    }
                }

                if (dtAbutmentPileRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtAbutmentPileRebar.Rows)
                    {
                        //PileRebarPara para = new PileRebarPara();
                        PileRebarPara para = DataTable2Model.FillModel<PileRebarPara>(dr);
                        para.project_type = project_type;
                        //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                        string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                        para.concrete_no = FinddictItem(sqlfindconcrete_no, para.concrete_no);
                        //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                        string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                        para.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.main_reinforcement_grade);
                        para.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.reinforcement_grade);
                        //string sqlfindpile_type = "select * from sys_dict_item where dict_id ='1706592047766376450' ";
                        string sqlfindpile_type = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='pile_type'  ";

                        para.pile_type = FinddictItem(sqlfindpile_type, para.pile_type);

                        int Pilestructure_number = 0;
                        System.Data.DataRow[] dtprow = dtA.Select("abutment_pile_steel_id='" + para.id + "' and abutment_pile_height ='"+ para.pile_length + "'");
                        if (dtprow.Length > 0)
                        {
                            for (int i = 0; i < dtprow.Length; i++)
                            {
                                string pile_structural_id = dtprow[i]["abutment_pile_id"].ToString();
                                string sqlA = "select * from busi_abutment_structural where  id='" + pile_structural_id + "'";
                                System.Data.DataTable dt = MySqlHelper.ExecuteDataTable(sqlA, CommandType.Text);
                                System.Data.DataRow drPile = dt.Rows[0];
                                busi_pile_structural pilePara = DataTable2Model.FillModel<busi_pile_structural>(drPile);
                                int Pilenumber = (2 + pilePara.span_w.Count(c => c == '+')) * (2 + pilePara.span_l.Count(c => c == '+'));
                                Pilestructure_number += Pilenumber;
                            }
                        }
                        para.structure_number = Pilestructure_number;
                        System.Data.DataTable dtnames = new System.Data.DataTable();
                        if (isMerge)
                        {
                            string sqlsteel = "select abutment_pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  abutment_pile_steel_id= '" + para.id + "' and abutment_pile_height ='"+ para.pile_length + "' and span_type = 'A' GROUP BY abutment_pile_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        else
                        {
                            string sqlsteel = "select abutment_pile_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  abutment_pile_steel_id= '" + para.id + "' and abutment_pile_height ='"+ para.pile_length + "' and span_type = 'A' GROUP BY abutment_pile_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        para.pier_name = dtnames.Rows[0]["names"].ToString();
                        AbutmentpileRebarList.Add(para);
                    }
                }

                #endregion

                #region 承台钢筋
                DataView dvPileCap = dtPileCapRebar.DefaultView;
                dtPileCapDis = dvPileCap.ToTable(true, new string[] { "configure_name" });

                if (dtPileCapRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtPileCapRebar.Rows)
                    {
                        PileCapRebarPara para = DataTable2Model.FillModel<PileCapRebarPara>(dr);
                        //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                        string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                        para.concrete_no = FinddictItem(sqlfindconcrete_no, para.concrete_no);
                        //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                        string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                        para.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.main_reinforcement_grade);
                        para.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, para.reinforcement_grade);
                        int count = dtP.AsEnumerable().Count(row => row.Field<string>("pile_cap_steel_id") == dr["id"].ToString());
                        para.structure_number = count;

                        System.Data.DataTable dtnames = new System.Data.DataTable();
                        if (isMerge)
                        {
                            string sqlsteel = "select pile_cap_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  pile_cap_steel_id= '" + para.id + "' and span_type = 'P' GROUP BY pile_cap_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        else 
                        {
                            string sqlsteel = "select pile_cap_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  pile_cap_steel_id= '" + para.id + "' and span_type = 'P' GROUP BY pile_cap_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        para.pier_name = dtnames.Rows[0]["names"].ToString();
                        pileCapRebarList.Add(para);
                    }
                }
                else
                {
                    isExistCap = false;
                }


                if (dtPierBeamRebar.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow dr in dtPierBeamRebar.Rows)
                    {
                        PierBeamRebarPara pierBeamRebarPara = DataTable2Model.FillModel<PierBeamRebarPara>(dr);
                        //string sqlfindconcrete_no = "select * from sys_dict_item where dict_id ='1704316916700450818' ";
                        string sqlfindconcrete_no = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='concrete_grade'";
                        pierBeamRebarPara.concrete_no = FinddictItem(sqlfindconcrete_no, pierBeamRebarPara.concrete_no);
                        //string sqlfindmain_reinforcement_grade = "select * from sys_dict_item where dict_id ='1704318260148604930' ";
                        string sqlfindmain_reinforcement_grade = "select * from sys_dict_item a inner join sys_dict b on a.dict_id=b.id where b.dict_code='steel_grade' ";
                        pierBeamRebarPara.main_reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierBeamRebarPara.main_reinforcement_grade);
                        pierBeamRebarPara.reinforcement_grade = FinddictItem(sqlfindmain_reinforcement_grade, pierBeamRebarPara.reinforcement_grade);
                        int count = dtP.AsEnumerable().Count(row => row.Field<string>("beam_steel_id") == dr["id"].ToString());
                        pierBeamRebarPara.structure_number = count;
                        System.Data.DataTable dtnames = new System.Data.DataTable();
                        if (isMerge)
                        {
                            string sqlsteel = "select beam_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_main_id = '" + maninid + "' and  beam_steel_id= '" + pierBeamRebarPara.id + "' and span_type = 'P' GROUP BY beam_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        else
                        {
                            string sqlsteel = "select beam_steel_id,GROUP_CONCAT(DISTINCT name SEPARATOR '、') AS names from vi_pier_structural where bridge_id = '" + bridgeId + "' and  beam_steel_id= '" + pierBeamRebarPara.id + "' and span_type = 'P' GROUP BY beam_steel_id";
                            dtnames = MySqlHelper.ExecuteDataTable(sqlsteel, CommandType.Text);
                        }
                        pierBeamRebarPara.pier_name = dtnames.Rows[0]["names"].ToString();
                        beamRebarList.Add(pierBeamRebarPara);
                    }
                }

                #endregion
            }
            dtProjectTb = dtProject;
        }
        public void DrawingPier(Database db, int OverAllScale)
        {
            try
            {
                if (dtProject.Rows[0][0].ToString() != "澜沧江")
                    Extensions.curTKPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\TK.dwg";
                else
                    Extensions.curTKPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\TK_LCJ.dwg";
                switch (sub_type)
                {
                    case PierSubstructureType.Pier:
                        #region 绘制图形
                        Extents2d ExtPierE, ExtPierS, ExtPierSection, ExtNote;
                        Point2d RefPtPierE, RefPtPierS, RefPtPierSectioon, RefPtNote;
                        RefPtPierE = Point2d.Origin;
                        ExtPierE = new Extents2d();
                        RefPtPierS = Point2d.Origin;
                        ExtPierS = new Extents2d();
                        RefPtPierSectioon = Point2d.Origin;
                        ExtPierSection = new Extents2d();
                        RefPtNote = Point2d.Origin;
                        ExtNote = new Extents2d();
                        List<Extents2d> lstPierExt = new List<Extents2d>();
                        List<Extents2d> lstPierSExt = new List<Extents2d>();
                        List<Extents2d> lstPierSectionExt = new List<Extents2d>();
                        List<Extents2d> lstPierNoteExt = new List<Extents2d>();
                        if (pierList.Count > 0)
                        {
                            double H = 0;
                            #region 逐墩合并
                            //List<PierPara> pierDisList = pierList;
                            //for (int i = 0; i < dtPDis.Rows.Count; i++)
                            //{

                            //    List<PierPara> pierDisList = pierList.FindAll(o => o.PierNo == dtPDis.Rows[i]["PierNo"].ToString());
                            //    PierPara pierPara = pierList.Find(o => o.PierNo == dtPDis.Rows[i]["PierNo"].ToString());
                            //    #region 立面绘制
                            //    RefPtPierE = Point2d.Origin.C2D();
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierE = Point2d.Origin.C2D(0, -H - 50 * OverAllScale * i);
                            //    ExtPierE = new Extents2d(RefPtPierE, RefPtPierE);
                            //    PierStructure_Merge.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale);

                            //    #endregion

                            //    #region 侧面绘制
                            //    RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale);
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale, -H - 50 * OverAllScale * i);
                            //    ExtPierS = new Extents2d(RefPtPierS, RefPtPierS);
                            //    PierStructure_Merge.PlotPierSide(ref db, ref ExtPierS, RefPtPierS, pierPara, OverAllScale);

                            //    #endregion

                            //    #region 侧面绘制
                            //    RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale);
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale, -H - 50 * OverAllScale * i);
                            //    ExtPierSection = new Extents2d(RefPtPierSectioon, RefPtPierSectioon);
                            //    PierStructure_Merge.PlotSection1(ref db, ref ExtPierSection, RefPtPierSectioon, pierPara, OverAllScale);

                            //    Point2d ptSection = RefPtPierSectioon.C2D(0, -ExtPierSection.L() - 15 * OverAllScale);
                            //    Extents2d ext = new Extents2d(ptSection, ptSection);
                            //    PierStructure_Merge.PlotSection2(ref db, ref ext, ptSection, pierPara, OverAllScale, ExtPierSection.W());
                            //    ExtPierSection = ExtPierSection.Add(ext);
                            //    #endregion

                            //    #region 注释和参数表格
                            //    RefPtNote = ptSection.C2D(-50 * OverAllScale, -ext.L() - 15 * OverAllScale);
                            //    ExtNote = new Extents2d(RefPtNote, RefPtNote);
                            //    PierStructure_Merge.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierDisList, OverAllScale);
                            //    #endregion
                            //    lstPierExt.Add(ExtPierE);
                            //    lstPierSExt.Add(ExtPierS);
                            //    lstPierSectionExt.Add(ExtPierSection);
                            //    lstPierNoteExt.Add(ExtNote);

                            //    H += ExtPierE.L();

                            //}
                            #endregion

                            #region 逐墩绘制
                            //List<PierPara> pierDisList = pierList;
                            for (int i = 0; i < pierList.Count; i++)
                            {

                                List<PierPara> pierDisList = pierList.FindAll(o => o.name == pierList[i].name && o.pier_height == pierList[i].pier_height);
                                //PierPara pierPara = pierList.Find(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                PierPara pierPara = pierList[i];
                                #region 立面绘制
                                RefPtPierE = Point2d.Origin.C2D();
                                if (lstPierExt.Count > 0)
                                    RefPtPierE = Point2d.Origin.C2D(0, -H - 50 * OverAllScale * i);
                                ExtPierE = new Extents2d(RefPtPierE, RefPtPierE);
                                if (pierDisList.Count == 2)
                                    PierStructure.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale, true);
                                else
                                    PierStructure.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale);
                                #endregion

                                #region 侧面绘制
                                RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale);
                                if (lstPierExt.Count > 0)
                                    RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale, -H - 50 * OverAllScale * i);
                                ExtPierS = new Extents2d(RefPtPierS, RefPtPierS);
                                PierStructure.PlotPierSide(ref db, ref ExtPierS, RefPtPierS, pierPara, OverAllScale);

                                #endregion

                                #region 侧面绘制
                                RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale);
                                if (lstPierExt.Count > 0)
                                    RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale, -H - 50 * OverAllScale * i);
                                ExtPierSection = new Extents2d(RefPtPierSectioon, RefPtPierSectioon);
                                PierStructure.PlotSection1(ref db, ref ExtPierSection, RefPtPierSectioon, pierPara, OverAllScale);

                                Point2d ptSection = RefPtPierSectioon.C2D(0, -ExtPierSection.L() - 15 * OverAllScale);
                                Extents2d ext = new Extents2d(ptSection, ptSection);
                                PierStructure.PlotSection2(ref db, ref ext, ptSection, pierPara, OverAllScale, ExtPierSection.W());
                                ExtPierSection = ExtPierSection.Add(ext);
                                #endregion

                                #region 注释和参数表格
                                RefPtNote = ptSection.C2D(-50 * OverAllScale, -ext.L() - 15 * OverAllScale);
                                ExtNote = new Extents2d(RefPtNote, RefPtNote);
                                if (pierDisList.Count == 2)
                                    PierStructure.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierPara, OverAllScale, false, true);
                                else
                                    PierStructure.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierPara, OverAllScale, false);
                                #endregion
                                lstPierExt.Add(ExtPierE);
                                lstPierSExt.Add(ExtPierS);
                                lstPierSectionExt.Add(ExtPierSection);
                                lstPierNoteExt.Add(ExtNote);

                                H += ExtPierE.L();
                                if (pierDisList.Count == 2)
                                {
                                    i++;
                                }
                            }
                            #endregion
                        }

                        #endregion

                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierLayout("图纸", lstPierExt, lstPierSExt, lstPierSectionExt, lstPierNoteExt, Extensions.leftWidth, Extensions.rightWidth, Extensions.bottomHeight, Extensions.topHeight, OverAllScale, lstPierExt.Count, 0);
                        Point2d tKPoint = Point2d.Origin;
                        for (int i = 0; i < lstPierExt.Count; i++)
                        {
                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 194, 13), ref ex, "引桥墩柱及基础一般构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 359, 13), ref ex, "S4-11-3-6", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[0][1].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 215, 12.5), ref ex, "设计1", 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 242, 12.5), ref ex, "复核1", 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 272, 12.5), ref ex, "审核1", 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 302, 12.5), ref ex, "审核2", 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 332, 12.5), ref ex, "审核3", 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[0][2].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, (i + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, (lstPierExt.Count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                        }
                        #endregion

                        break;

                    case PierSubstructureType.PileRebar:

                        #region 绘制图形
                        OverAllScale = 5;
                        OverAllScale = int.Parse(dtProject.Rows[4][3].ToString());
                        List<Extents2d> ExtPileLst = new List<Extents2d>(), ExtLPileLst = new List<Extents2d>(), ExtCPileLst = new List<Extents2d>(), ExtDetailLst = new List<Extents2d>();
                        Extents2d ExtPile, ExtLPile, ExtCPile, ExtDetail, extE;
                        Point2d RefPtPile, RefPtLPile, RefPtCPile, RefPtDetail;
                        RefPtPile = Point2d.Origin;
                        extE = new Extents2d(RefPtPile, RefPtPile);


                        if (pileRebarList.Count > 0)
                        {
                            //for (int i = 0; i < pileRebarList.Count; i++)
                            for (int i = 0; i < dtPileDis.Rows.Count; i++)
                            {
                                List<PileRebarPara> pierDisList = pileRebarList.FindAll(o => o.configure_name == dtPileDis.Rows[i]["configure_name"].ToString());
                                PileRebarPara pierPara = pileRebarList.Find(o => o.configure_name == dtPileDis.Rows[i]["configure_name"].ToString());
                                try
                                {
                                    PileRebar pileRebar = new PileRebar(pierPara,_bridgeId, isExistCap);
                                    if (ExtPileLst.Count > 0)
                                        RefPtPile = RefPtPile.C2D(extE.W() * 1.2, 0);
                                    extE = new Extents2d(RefPtPile, RefPtPile);
                                    pileRebar.PlotPile(ref db, out ExtPile, RefPtPile, OverAllScale);
                                    ExtPileLst.Add(ExtPile);
                                    RefPtLPile = RefPtPile.C2D(ExtPile.W() + 20 * OverAllScale, -ExtPile.L() + pileRebarList[i].bottom_distance + 15 * OverAllScale);
                                    if (pierPara.is_out_double_layout)
                                    {
                                        RefPtPile.C2D(ExtPile.W() + 5 * OverAllScale, -ExtPile.L() + pileRebarList[i].bottom_distance + 15 * OverAllScale);
                                    }
                                    pileRebar.PlotPileSpiral(ref db, out ExtLPile, RefPtLPile, OverAllScale);
                                    ExtLPileLst.Add(ExtLPile);

                                    RefPtCPile = RefPtPile.C2D(ExtPile.W() + 20 * OverAllScale, 0);
                                    pileRebar.PlotCPile(ref db, out ExtCPile, RefPtCPile, OverAllScale);
                                    ExtCPileLst.Add(ExtCPile);

                                    RefPtDetail = RefPtCPile.C2D(ExtLPile.W() + 5 * OverAllScale, -ExtCPile.L() - 3 * OverAllScale);
                                    pileRebar.RendeDetail(ref db, RefPtDetail, out ExtDetail, pierDisList, OverAllScale);
                                    ExtDetailLst.Add(ExtDetail);

                                    extE = extE.Add(ExtCPile);
                                    extE = extE.Add(ExtDetail);

                                }
                                catch (Exception ex)
                                {

                                }
                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion


                        #region 模型空间到布局空间投影处理
                        LayoutTools.CreatePierSubPileLayout(db, "图纸", ExtPileLst, ExtLPileLst, ExtCPileLst, ExtDetailLst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                        Point2d tKPointPile = Point2d.Origin;
                        int ANum = 1;
                        ANum = pileRebarList.FindAll(o => o.configure_name.Contains("A")).Count;
                        int startA = 1, startP = 1;
                        for (int i = 0; i < ExtPileLst.Count; i++)
                        {

                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 194, 13), ref ex, "引桥桩基钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 359, 13), ref ex, "S4-11-3-11", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);


                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            if (pileRebarList[i].configure_name.Contains("A"))
                            {
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[5][1].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[5][2].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, startA.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, ANum.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                startA++;
                            }
                            else
                            {
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[4][1].ToString(), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[4][2].ToString(), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, (startP).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, (ExtPileLst.Count - ANum).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                startP++;
                            }

                        }
                        #endregion
                        break;

                    case PierSubstructureType.PileCapRebar:
                        #region 绘制图形
                        OverAllScale = 8;
                        OverAllScale = int.Parse(dtProject.Rows[3][3].ToString());
                        List<Extents2d> ExtPileCapALst = new List<Extents2d>(), ExtPileCapBLst = new List<Extents2d>(), ExtPileCapPLst = new List<Extents2d>(), ExtPileCapDetailLst = new List<Extents2d>();
                        Extents2d ExtPileCapA, ExtPileCapB, ExtPileCapP, ExtPileCapDetail, extPileCapE;
                        Point2d RefPtPileCapA, RefPtPileCapB, RefPtPileCapP, RefPtPileCapDetail;
                        RefPtPileCapA = Point2d.Origin;
                        extPileCapE = new Extents2d(RefPtPileCapA, RefPtPileCapA);


                        if (pileCapRebarList.Count > 0)
                        {
                            //for (int i = 0; i < pileRebarList.Count; i++)
                            for (int i = 0; i < dtPileCapDis.Rows.Count; i++)
                            {
                                List<PileCapRebarPara> pierDisList = pileCapRebarList.FindAll(o => o.configure_name == dtPileCapDis.Rows[i]["configure_name"].ToString());
                                PileCapRebarPara pierPara = pileCapRebarList.Find(o => o.configure_name == dtPileCapDis.Rows[i]["configure_name"].ToString());
                                try
                                {
                                    PileCapRebar pileRebar = new PileCapRebar(pierPara);
                                    if (ExtPileCapALst.Count > 0)
                                    {
                                        if (pierPara.width > pierPara.length)
                                        {
                                            RefPtPileCapA = RefPtPileCapA.C2D(extPileCapE.W() * 1.5, 0);
                                        }
                                        else
                                        {
                                            RefPtPileCapA = RefPtPileCapA.C2D(extPileCapE.W() * 1.2, 0);
                                        }
                                    }
                                    extPileCapE = new Extents2d(RefPtPileCapA, RefPtPileCapA);
                                    pileRebar.PlotElevationA(ref db, out ExtPileCapA, RefPtPileCapA, OverAllScale);
                                    ExtPileCapALst.Add(ExtPileCapA);
                                    if (pierPara.width > pierPara.length)
                                    {
                                        RefPtPileCapB = RefPtPileCapA.C2D(ExtPileCapA.W() + 50 * OverAllScale, 0);
                                        pileRebar.PlotElevationB(ref db, out ExtPileCapB, RefPtPileCapB, OverAllScale);
                                        ExtPileCapBLst.Add(ExtPileCapB);
                                    }
                                    else
                                    {
                                        RefPtPileCapB = RefPtPileCapA.C2D(ExtPileCapA.W() + 20 * OverAllScale, 0);
                                        pileRebar.PlotElevationB(ref db, out ExtPileCapB, RefPtPileCapB, OverAllScale);
                                        ExtPileCapBLst.Add(ExtPileCapB);
                                    }

                                    RefPtPileCapP = RefPtPileCapA.C2D(0, -ExtPileCapA.L() - 20 * OverAllScale);
                                    pileRebar.PlotElevationPlan(ref db, out ExtPileCapP, RefPtPileCapP, OverAllScale);
                                    ExtPileCapPLst.Add(ExtPileCapP);

                                    if (pierPara.width > pierPara.length)
                                    {
                                        RefPtPileCapDetail = RefPtPileCapP.C2D(ExtPileCapP.W() + 20 * OverAllScale, 0);
                                        pileRebar.RendeDetail(ref db, out ExtPileCapDetail, RefPtPileCapDetail, OverAllScale);
                                        ExtPileCapDetailLst.Add(ExtPileCapDetail);
                                    }
                                    else
                                    {
                                        RefPtPileCapDetail = RefPtPileCapP.C2D(ExtPileCapP.W() + 5 * OverAllScale, 0);
                                        pileRebar.RendeDetail(ref db, out ExtPileCapDetail, RefPtPileCapDetail, OverAllScale);
                                        ExtPileCapDetailLst.Add(ExtPileCapDetail);
                                    }

                                    extPileCapE = extPileCapE.Add(ExtPileCapA);
                                    extPileCapE = extPileCapE.Add(ExtPileCapDetail);

                                }
                                catch (Exception ex)
                                {

                                }
                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion

                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierSubPileCapLayout(db, "图纸", ExtPileCapALst, ExtPileCapBLst, ExtPileCapPLst, ExtPileCapDetailLst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                        Point2d tKPointPileCap = Point2d.Origin;
                        for (int i = 0; i < ExtPileCapALst.Count; i++)
                        {
                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 194, 13), ref ex, "引桥承台钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 359, 13), ref ex, "S4-11-3-9", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[3][1].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[3][2].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, (i + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, (ExtPileCapALst.Count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                        }
                        #endregion
                        break;

                    case PierSubstructureType.PierRebar:
                        #region 绘制图形
                        OverAllScale = 10;
                        double extendscale = 5 / 6.0;
                        InitConfig.InitDimExtendStyle(Unit.Millimeter, Unit.Millimeter, OverAllScale, extendscale, "SRB.HT");
                        InitConfig.InitDimExtendStyle(Unit.Centimeter, Unit.Centimeter, OverAllScale, extendscale, "SRB.HT");
                        //List<Extents2d> ExtPierALst = new List<Extents2d>(), ExtPierBLst = new List<Extents2d>(), ExtPierCLst = new List<Extents2d>(), ExtPierDLst = new List<Extents2d>(), ExtPierNote1Lst = new List<Extents2d>(), ExtPierNote2Lst = new List<Extents2d>(),
                        //    ExtPierELst = new List<Extents2d>(), ExtPierFLst = new List<Extents2d>(), ExtPierGLst = new List<Extents2d>(), ExtPierHLst = new List<Extents2d>();
                        List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>> tuPage1Lst = new List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>>();
                        List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>> tuPage2Lst = new List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>>();
                        List<Tuple<Extents2d>> tuPage3Lst = new List<Tuple<Extents2d>>();
                        List<Tuple<Extents2d>> tuPage4Lst = new List<Tuple<Extents2d>>();
                        Extents2d ExtPierReA, ExtPierReB, ExtPierReC, ExtPierReD, ExtPierReE, ExtPierReF, ExtPierReG, ExtPierReBA, ExtPierReBB, ExtPierReBP, ExtPierReNote1, ExtPierReNote2;
                        Point2d RefPtPierReA, RefPtPierReB, RefPtPierReC, RefPtPierReD, RefPtPierReE, RefPtPierReF, RefPtPierReG, RefPtPierReBA, RefPtPierReBB, RefPtPierReBP, RefPtPierReNote1, RefPtPierReNote2;
                        RefPtPierReA = Point2d.Origin;
                        ExtPierReA = new Extents2d(RefPtPierReA, RefPtPierReA);
                        Extents2d ExtPierReS, ExtPierRebar;
                        Point2d RefPtPierReS, RefPtPierRebar;
                        Extents2d Ext = new Extents2d(RefPtPierReA, RefPtPierReA);
                        if (pierList.Count > 0)
                        {
                            double H = 0;
                            //List<PierPara> pierDisList = pierList;
                            for (int i = 0; i < dtPDis.Rows.Count; i++)
                            {

                                List<PierPara> pierDisList = pierList.FindAll(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                PierPara pierPara = pierList.Find(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                try
                                {
                                    PierRebar pierRebar = new PierRebar(pierPara, extendscale);
                                    #region  第一页
                                    List<Extents2d> lst = new List<Extents2d>();
                                    if (tuPage1Lst.Count > 0)
                                        RefPtPierReA = RefPtPierReA.C2D(0, -Ext.L() * 1.5);
                                    Ext = new Extents2d(RefPtPierReA, RefPtPierReA);
                                    ExtPierReA = new Extents2d(RefPtPierReA, RefPtPierReA);
                                    pierRebar.PlotPierelEvationA(ref db, out ExtPierReA, RefPtPierReA, OverAllScale);
                                    lst.Add(ExtPierReA);
                                    Ext = Ext.Add(ExtPierReA);

                                    RefPtPierReC = RefPtPierReA.C2D(ExtPierReA.W() + 20 * OverAllScale, 0);
                                    pierRebar.PlotPierSideB(ref db, out ExtPierReC, RefPtPierReC, OverAllScale);
                                    lst.Add(ExtPierReC);
                                    Ext = Ext.Add(ExtPierReC);

                                    RefPtPierReE = RefPtPierReC.C2D(ExtPierReA.W() + 20 * OverAllScale);
                                    pierRebar.PlotSectionEE(ref db, out ExtPierReE, RefPtPierReE, OverAllScale);
                                    lst.Add(ExtPierReE);

                                    RefPtPierReF = RefPtPierReC.C2D(ExtPierReA.W() + 20 * OverAllScale, -ExtPierReE.L() - 8 * OverAllScale);
                                    pierRebar.PlotSectionFF(ref db, out ExtPierReF, RefPtPierReF, OverAllScale);
                                    lst.Add(ExtPierReF);

                                    RefPtPierReG = RefPtPierReF.C2D(0, -ExtPierReF.L() - 8 * OverAllScale);
                                    pierRebar.PlotSectionGG(ref db, out ExtPierReG, RefPtPierReG, OverAllScale);
                                    lst.Add(ExtPierReG);

                                    //RefPtPierReNote1 = RefPtPierReG.C2D(-ExtPierReG.W() * 0.5, -ExtPierReG.L() - 5 * OverAllScale);
                                    //pierRebar.PlotPierNote(ref db, out ExtPierReNote1, RefPtPierReNote1, OverAllScale);
                                    //lst.Add(ExtPierReNote1);

                                    Ext = Ext.Add(ExtPierReG);

                                    Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d> tuPage1 = new Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>(ExtPierReA, ExtPierReC, ExtPierReE, ExtPierReF, ExtPierReG);
                                    tuPage1Lst.Add(tuPage1);
                                    #endregion

                                    #region  第二页
                                    lst = new List<Extents2d>();
                                    RefPtPierReB = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);

                                    ExtPierReB = new Extents2d(RefPtPierReB, RefPtPierReB);
                                    pierRebar.PlotPierelEvationC(ref db, out ExtPierReB, RefPtPierReB, OverAllScale);
                                    lst.Add(ExtPierReB);
                                    Ext = Ext.Add(ExtPierReB);

                                    RefPtPierReD = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, 0);
                                    pierRebar.PlotPierSideD(ref db, out ExtPierReD, RefPtPierReD, OverAllScale);
                                    lst.Add(ExtPierReD);
                                    Ext = Ext.Add(ExtPierReD);

                                    RefPtPierReBA = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, 0);
                                    pierRebar.PlotPierBlockA(ref db, out ExtPierReBA, RefPtPierReBA, OverAllScale);
                                    lst.Add(ExtPierReBA);

                                    RefPtPierReBB = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, -ExtPierReBA.L() - 15 * OverAllScale);
                                    pierRebar.PlotPierBlockB(ref db, out ExtPierReBB, RefPtPierReBB, OverAllScale);
                                    lst.Add(ExtPierReBB);

                                    RefPtPierReBP = RefPtPierReBB.C2D(0, -ExtPierReBB.L() - 15 * OverAllScale);
                                    pierRebar.PlotPierBlockPlan(ref db, out ExtPierReBP, RefPtPierReBP, OverAllScale);
                                    lst.Add(ExtPierReBP);

                                    RefPtPierReNote2 = RefPtPierReBP.C2D(-ExtPierReBP.W() * 0.5, -ExtPierReBP.L() - 10 * OverAllScale);
                                    //RefPtPierReNote2 = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, -ExtPierReBP.L() - 10 * OverAllScale);
                                    pierRebar.PlotPierNote(ref db, out ExtPierReNote2, RefPtPierReNote2, pierDisList, OverAllScale);
                                    lst.Add(ExtPierReNote2);
                                    Ext = Ext.Add(ExtPierReNote2);
                                    Ext = Ext.Add(ExtPierReBP);
                                    Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d> tuPage2 = new Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>(ExtPierReB, ExtPierReD, ExtPierReBB, ExtPierReBA, ExtPierReBP, ExtPierReNote2);
                                    tuPage2Lst.Add(tuPage2);
                                    #endregion

                                    #region  第三页
                                    lst = new List<Extents2d>();
                                    RefPtPierReS = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);
                                    pierRebar.PlotPierSample(ref db, out ExtPierReS, RefPtPierReS, OverAllScale);
                                    lst.Add(ExtPierReS);
                                    Ext = Ext.Add(ExtPierReS);
                                    Tuple<Extents2d> tuPage3 = new Tuple<Extents2d>(ExtPierReS);
                                    tuPage3Lst.Add(tuPage3);
                                    #endregion

                                    #region  第四页
                                    lst = new List<Extents2d>();
                                    RefPtPierRebar = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);
                                    pierRebar.PlotPierRebarTable(ref db, out ExtPierRebar, RefPtPierRebar, OverAllScale, pierDisList);
                                    lst.Add(ExtPierRebar);
                                    Ext = Ext.Add(ExtPierRebar);
                                    Tuple<Extents2d> tuPage4 = new Tuple<Extents2d>(ExtPierRebar);
                                    tuPage4Lst.Add(tuPage4);
                                    #endregion
                                }
                                catch (Exception ex)
                                {

                                }
                            }
                        }

                        #endregion

                        #region 模型空间到布局空间投影处理
                        int pdfnum = 4;
                        LayoutTools.CreatePierSubPierLayout(db, "图纸", tuPage1Lst, tuPage2Lst, tuPage3Lst, tuPage4Lst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale, extendscale);
                        Point2d tKPointPier = Point2d.Origin;
                        for (int i = 0; i < tuPage1Lst.Count; i++)
                        {
                            for (int j = 0; j < pdfnum; j++)
                            {
                                Extents2d ex = new Extents2d();
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 194, 13 - 297 * i), ref ex, "引桥墩身钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 245, 13 - 297 * i), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 281, 13 - 297 * i), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 315, 13 - 297 * i), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 359, 13 - 297 * i), ref ex, "S4-11-3-8", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 400.5, 13 - 297 * i), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + 161, 12.5 - 297 * i), ref ex, dtProject.Rows[2][1].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + 366, 12.5 - 297 * i), ref ex, dtProject.Rows[2][2].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 400, 12.5 - 297 * i), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                                TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + 420 - 33, 297 - 16.5 - 297 * i), ref ex, (pdfnum * i + j + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + 420 - 16.5, 297 - 16.5 - 297 * i), ref ex, (tuPage1Lst.Count * pdfnum).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            }
                        }
                        #endregion
                        break;

                    case PierSubstructureType.BeamRebar:
                        #region 绘制图形
                        OverAllScale = 8;
                        List<Extents2d> ExtBeamLst = new List<Extents2d>(), ExtBeamALst = new List<Extents2d>(), ExtBeamDetailLst = new List<Extents2d>();
                        Extents2d ExtBeam, ExtBeamA, ExtBeamDetail, ExtBRebar;
                        Point2d RefPtBeam, RefPtBeamA, RefPtBeamDetail;
                        Point2d ptOrigin = Point2d.Origin;
                        RefPtBeam = Point2d.Origin;
                        ExtBeam = new Extents2d(RefPtBeam, RefPtBeam);
                        ExtBRebar = new Extents2d(RefPtBeam, RefPtBeam);

                        if (pierList.Count > 0)
                        {
                            double H = 0;
                            //List<PierPara> pierDisList = pierList;
                            for (int i = 0; i < beamRebarList.Count; i++)
                            {

                                List<PierPara> pierDisList = pierList.FindAll(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                PierPara pierPara = pierList.Find(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                try
                                {
                                    if (dtProject.Rows[0][0].ToString() != "澜沧江")
                                    {
                                        PierBeamRebar beamRebar = new PierBeamRebar(pierPara, beamRebarList[i]);
                                        if (ExtBeamLst.Count > 0)
                                            RefPtBeam = ptOrigin.C2D(ExtBRebar.W() + 50 * OverAllScale, 0);
                                        extPileCapE = new Extents2d(RefPtBeam, RefPtBeam);
                                        beamRebar.PlotElevation(ref db, out ExtBeam, RefPtBeam, OverAllScale);
                                        ExtBeamLst.Add(ExtBeam);
                                        ExtBRebar = ExtBRebar.Add(ExtBeam);

                                        RefPtBeamA = RefPtBeam.C2D(ExtBeam.W() + 20 * OverAllScale, 0);
                                        beamRebar.PlotElevationA(ref db, out ExtBeamA, RefPtBeamA, OverAllScale);
                                        ExtBeamALst.Add(ExtBeamA);
                                        ExtBRebar = ExtBRebar.Add(ExtBeamA);


                                        RefPtBeamDetail = RefPtBeamA.C2D(ExtBeamA.W() + 20 * OverAllScale, 0);
                                        beamRebar.RendeDetail(ref db, out ExtBeamDetail, RefPtBeamDetail, OverAllScale);
                                        ExtBeamDetailLst.Add(ExtBeamDetail);
                                        ExtBRebar = ExtBRebar.Add(ExtBeamDetail);
                                    }
                                    else
                                    {
                                        PierBeamRebarLCJ beamRebar = new PierBeamRebarLCJ(pierPara, beamRebarList[i]);
                                        if (ExtBeamLst.Count > 0)
                                            RefPtBeam = ptOrigin.C2D(ExtBRebar.W() + 50 * OverAllScale, 0);
                                        extPileCapE = new Extents2d(RefPtBeam, RefPtBeam);
                                        beamRebar.PlotElevation(ref db, out ExtBeam, RefPtBeam, OverAllScale);
                                        ExtBeamLst.Add(ExtBeam);
                                        ExtBRebar = ExtBRebar.Add(ExtBeam);

                                        RefPtBeamA = RefPtBeam.C2D(ExtBeam.W() + 20 * OverAllScale, 0);
                                        beamRebar.PlotElevationA(ref db, out ExtBeamA, RefPtBeamA, OverAllScale);
                                        ExtBeamALst.Add(ExtBeamA);
                                        ExtBRebar = ExtBRebar.Add(ExtBeamA);


                                        RefPtBeamDetail = RefPtBeamA.C2D(ExtBeamA.W() + 20 * OverAllScale, 0);
                                        beamRebar.RendeDetail(ref db, out ExtBeamDetail, RefPtBeamDetail, OverAllScale);
                                        ExtBeamDetailLst.Add(ExtBeamDetail);
                                        ExtBRebar = ExtBRebar.Add(ExtBeamDetail);
                                    }
                                    //extPileCapE = extPileCapE.Add(ExtPileCapA);
                                    //extPileCapE = extPileCapE.Add(ExtPileCapDetail);

                                }
                                catch (Exception ex)
                                {

                                }

                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion
                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierBeamLayout(db, "图纸", ExtBeamLst, ExtBeamALst, ExtBeamDetailLst, Extensions.leftWidth, Extensions.rightWidth, Extensions.bottomHeight, Extensions.topHeight, OverAllScale, ExtBeamLst.Count, 0);
                        tKPoint = Point2d.Origin;
                        for (int i = 0; i < ExtBeamLst.Count; i++)
                        {
                            Extents2d ex = new Extents2d();

                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[1][1].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[1][2].ToString(), 1, 4, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, (i + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, (ExtBeamLst.Count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                        }
                        #endregion
                        break;
                }
            }
            catch (Exception ex)
            {

            }
        }
        public void GetDrawingPierindex(ref int index)
        {
            try
            {
                switch (sub_type)
                {
                    case PierSubstructureType.Pier:
                        if (pierList.Count > 0)
                        {
                            index = pierList.Count;
                        }
                        break;

                    case PierSubstructureType.PileRebar:
                        if (pileRebarList.Count > 0)
                        {
                            index = pileRebarList.Count;
                        }
                        break;

                    case PierSubstructureType.PileCapRebar:

                        if (pileCapRebarList.Count > 0)
                        {
                            index = dtPileCapDis.Rows.Count;
                        }
                        break;

                    case PierSubstructureType.PierRebar:

                        if (pierList.Count > 0)
                        {
                            index = dtPDis.Rows.Count;
                        }
                        break;

                    case PierSubstructureType.BeamRebar:
                        if (pierList.Count > 0)
                        {
                            index = beamRebarList.Count;
                        }
                        break;

                    case PierSubstructureType.AbutmentPileRebar:
                        if (AbutmentpileRebarList.Count > 0)
                        {
                            index = AbutmentpileRebarList.Count;
                        }
                        break;
                }
            }
            catch (Exception ex)
            {

            }
        }
        public bool DrawingPierGetOne(Database db, int OverAllScale, int index, int count, string bridgeId, out System.Data.DataTable dtProjectConfigTb,string catalogid,int selectnum = 0)
        {
            bool Flag = false;
            try
            {
                Extensions.curTKPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\TK.dwg";
                string sqlBridgeConfig = "select * from busi_project_config where bridge_id='" + bridgeId + "'";
                dtProjectConfig = MySqlHelper.ExecuteDataTable(sqlBridgeConfig, CommandType.Text);
                PictureFrameTools.GetBridgeConfig(dtProjectConfig);
                //if (dtProject.Rows[0][0].ToString() != "澜沧江")
                //    Extensions.curTKPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\TK.dwg";
                //else
                //    Extensions.curTKPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\TK_LCJ.dwg";
                switch (sub_type)
                {
                    case PierSubstructureType.Pier:
                        #region 绘制图形
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;
                        //OverAllScale = int.Parse(dtProject.Rows[0][3].ToString());
                        Extents2d ExtPierE, ExtPierS, ExtPierSection, ExtNote;
                        Point2d RefPtPierE, RefPtPierS, RefPtPierSectioon, RefPtNote;
                        RefPtPierE = Point2d.Origin;
                        ExtPierE = new Extents2d();
                        RefPtPierS = Point2d.Origin;
                        ExtPierS = new Extents2d();
                        RefPtPierSectioon = Point2d.Origin;
                        ExtPierSection = new Extents2d();
                        RefPtNote = Point2d.Origin;
                        ExtNote = new Extents2d();
                        List<Extents2d> lstPierExt = new List<Extents2d>();
                        List<Extents2d> lstPierSExt = new List<Extents2d>();
                        List<Extents2d> lstPierSectionExt = new List<Extents2d>();
                        List<Extents2d> lstPierNoteExt = new List<Extents2d>();
                        List<PierPara> pierListGetone = new List<PierPara>();

                        int pierpdfnum = 0;
                        for (int i = 0; i < pierList.Count; i++)
                        {
                            List<PierPara> pierDisList = pierList.FindAll(o => o.name == pierList[i].name && o.pier_height == pierList[i].pier_height);
                            if (pierDisList.Count == 2)
                            {
                                i++;
                            }
                            pierpdfnum++;
                        }

                        pierListGetone.Add(pierList[index]);
                        if (pierListGetone.Count > 0)
                        {
                            double H = 0;
                            #region 逐墩合并
                            //List<PierPara> pierDisList = pierListGetone;
                            //for (int i = 0; i < dtPDis.Rows.Count; i++)
                            //{

                            //    List<PierPara> pierDisList = pierListGetone.FindAll(o => o.name == dtPDis.Rows[i]["name"].ToString());
                            //    PierPara pierPara = pierListGetone.Find(o => o.name == dtPDis.Rows[i]["name"].ToString());
                            //    #region 立面绘制
                            //    RefPtPierE = Point2d.Origin.C2D();
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierE = Point2d.Origin.C2D(0, -H - 50 * OverAllScale * i);
                            //    ExtPierE = new Extents2d(RefPtPierE, RefPtPierE);
                            //    PierStructure_Merge.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale);

                            //    #endregion

                            //    #region 侧面绘制
                            //    RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale);
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale, -H - 50 * OverAllScale * i);
                            //    ExtPierS = new Extents2d(RefPtPierS, RefPtPierS);
                            //    PierStructure_Merge.PlotPierSide(ref db, ref ExtPierS, RefPtPierS, pierPara, OverAllScale);

                            //    #endregion

                            //    #region 侧面绘制
                            //    RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale);
                            //    if (lstPierExt.Count > 0)
                            //        RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale, -H - 50 * OverAllScale * i);
                            //    ExtPierSection = new Extents2d(RefPtPierSectioon, RefPtPierSectioon);
                            //    PierStructure_Merge.PlotSection1(ref db, ref ExtPierSection, RefPtPierSectioon, pierPara, OverAllScale);

                            //    Point2d ptSection = RefPtPierSectioon.C2D(0, -ExtPierSection.L() - 15 * OverAllScale);
                            //    Extents2d ext = new Extents2d(ptSection, ptSection);
                            //    PierStructure_Merge.PlotSection2(ref db, ref ext, ptSection, pierPara, OverAllScale, ExtPierSection.W());
                            //    ExtPierSection = ExtPierSection.Add(ext);
                            //    #endregion

                            //    #region 注释和参数表格
                            //    RefPtNote = ptSection.C2D(-50 * OverAllScale, -ext.L() - 15 * OverAllScale);
                            //    ExtNote = new Extents2d(RefPtNote, RefPtNote);
                            //    PierStructure_Merge.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierDisList, OverAllScale);
                            //    #endregion
                            //    lstPierExt.Add(ExtPierE);
                            //    lstPierSExt.Add(ExtPierS);
                            //    lstPierSectionExt.Add(ExtPierSection);
                            //    lstPierNoteExt.Add(ExtNote);

                            //    H += ExtPierE.L();

                            //}
                            #endregion

                            #region 逐墩绘制
                            //List<PierPara> pierDisList = pierListGetone;
                            for (int i = 0; i < pierListGetone.Count; i++)
                            {

                                List<PierPara> pierDisList = pierList.FindAll(o => o.name == pierList[index].name && o.pier_height == pierList[index].pier_height);
                                //PierPara pierPara = pierListGetone.Find(o => o.name == dtPDis.Rows[i]["name"].ToString());
                                PierPara pierPara = pierListGetone[0];
                                #region 立面绘制
                                RefPtPierE = Point2d.Origin.C2D();
                                if (lstPierExt.Count > 0)
                                    RefPtPierE = Point2d.Origin.C2D(0, -H - 50 * OverAllScale * index);
                                ExtPierE = new Extents2d(RefPtPierE, RefPtPierE);
                                if (pierDisList.Count == 2)
                                    PierStructure.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale, true);
                                else
                                    PierStructure.PlotPierelEvation(ref db, ref ExtPierE, RefPtPierE, pierPara, OverAllScale);
                                #endregion

                                #region 侧面绘制
                                RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale);
                                if (lstPierExt.Count > 0)
                                    RefPtPierS = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale, -H - 50 * OverAllScale * index);
                                ExtPierS = new Extents2d(RefPtPierS, RefPtPierS);
                                PierStructure.PlotPierSide(ref db, ref ExtPierS, RefPtPierS, pierPara, OverAllScale);

                                #endregion

                                #region 侧面绘制
                                RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale);
                                if (lstPierExt.Count > 0)
                                    RefPtPierSectioon = Point2d.Origin.C2D(ExtPierE.W() + 20 * OverAllScale + ExtPierS.W() + 100 * OverAllScale, -H - 50 * OverAllScale * index);
                                ExtPierSection = new Extents2d(RefPtPierSectioon, RefPtPierSectioon);
                                PierStructure.PlotSection1(ref db, ref ExtPierSection, RefPtPierSectioon, pierPara, OverAllScale);

                                Point2d ptSection = RefPtPierSectioon.C2D(0, -ExtPierSection.L() - 15 * OverAllScale);
                                Extents2d ext = new Extents2d(ptSection, ptSection);
                                PierStructure.PlotSection2(ref db, ref ext, ptSection, pierPara, OverAllScale, ExtPierSection.W());
                                ExtPierSection = ExtPierSection.Add(ext);
                                #endregion

                                #region 注释和参数表格
                                RefPtNote = ptSection.C2D(-50 * OverAllScale, -ext.L() - 15 * OverAllScale);
                                ExtNote = new Extents2d(RefPtNote, RefPtNote);
                                if (pierDisList.Count == 2)
                                    PierStructure.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierPara, OverAllScale, false, true);
                                else
                                    PierStructure.PlotPierNote(ref db, ref ExtNote, RefPtNote, pierPara, OverAllScale, false);
                                #endregion
                                lstPierExt.Add(ExtPierE);
                                lstPierSExt.Add(ExtPierS);
                                lstPierSectionExt.Add(ExtPierSection);
                                lstPierNoteExt.Add(ExtNote);

                                H += ExtPierE.L();
                                if (pierDisList.Count == 2)
                                {
                                    Flag = true;
                                }
                            }
                            #endregion
                        }

                        #endregion

                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierLayout("图纸", lstPierExt, lstPierSExt, lstPierSectionExt, lstPierNoteExt, Extensions.leftWidth, Extensions.rightWidth, Extensions.bottomHeight, Extensions.topHeight, OverAllScale, lstPierExt.Count, 0);
                        Point2d tKPoint = Point2d.Origin;
                        for (int i = 0; i < lstPierExt.Count; i++)
                        {
                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 194, 13), ref ex, "引桥墩柱及基础一般构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 359, 13), ref ex, "S4-11-3-6", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPoint.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y), ref ex, (selectnum + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y), ref ex, pierpdfnum.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            PictureFrameTools.AddPaperDBText(db, tKPoint, i, drawingConfigModel, ref ex, selectnum + 1, pierpdfnum);

                        }
                        #endregion

                        break;

                    case PierSubstructureType.PileRebar:

                        #region 绘制图形
                        OverAllScale = 5;
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;

                        List<Extents2d> ExtPileLst = new List<Extents2d>(), ExtLPileLst = new List<Extents2d>(), ExtCPileLst = new List<Extents2d>(), ExtDetailLst = new List<Extents2d>();
                        Extents2d ExtPile, ExtLPile, ExtCPile, ExtDetail, extE;
                        Point2d RefPtPile, RefPtLPile, RefPtCPile, RefPtDetail;
                        RefPtPile = Point2d.Origin;
                        extE = new Extents2d(RefPtPile, RefPtPile);
                        List<PileRebarPara> pileRebarListGetone = new List<PileRebarPara>();
                        if (pileRebarList.Count > 0)
                        {
                            pileRebarListGetone.Add(pileRebarList[index]);
                            //for (int i = 0; i < pileRebarList.Count; i++)
                            List<PileRebarPara> pierDisList = pileRebarListGetone;
                            PileRebarPara pierPara = pileRebarListGetone[0];
                            try
                            {
                                PileRebar pileRebar = new PileRebar(pierPara,_bridgeId, isExistCap);
                                if (ExtPileLst.Count > 0)
                                    RefPtPile = RefPtPile.C2D(extE.W() * 1.2, 0);
                                extE = new Extents2d(RefPtPile, RefPtPile);
                                pileRebar.PlotPile(ref db, out ExtPile, RefPtPile, OverAllScale);
                                ExtPileLst.Add(ExtPile);
                                RefPtLPile = RefPtPile.C2D(ExtPile.W() + 20 * OverAllScale, -ExtPile.L() + pileRebarListGetone[0].bottom_distance + 15 * OverAllScale);
                                if (pierPara.is_out_double_layout)
                                {
                                    RefPtPile.C2D(ExtPile.W() + 5 * OverAllScale, -ExtPile.L() + pileRebarListGetone[0].bottom_distance + 15 * OverAllScale);
                                }
                                pileRebar.PlotPileSpiral(ref db, out ExtLPile, RefPtLPile, OverAllScale);
                                ExtLPileLst.Add(ExtLPile);

                                RefPtCPile = RefPtPile.C2D(ExtPile.W() + 20 * OverAllScale, 0);
                                pileRebar.PlotCPile(ref db, out ExtCPile, RefPtCPile, OverAllScale);
                                ExtCPileLst.Add(ExtCPile);

                                RefPtDetail = RefPtCPile.C2D(ExtLPile.W() + 5 * OverAllScale, -ExtCPile.L() - 3 * OverAllScale);
                                pileRebar.RendeDetail(ref db, RefPtDetail, out ExtDetail, pierDisList, OverAllScale);
                                ExtDetailLst.Add(ExtDetail);

                                extE = extE.Add(ExtCPile);
                                extE = extE.Add(ExtDetail);

                            }
                            catch (Exception ex)
                            {

                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion


                        #region 模型空间到布局空间投影处理
                        LayoutTools.CreatePierSubPileLayout(db, "图纸", ExtPileLst, ExtLPileLst, ExtCPileLst, ExtDetailLst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                        Point2d tKPointPile = Point2d.Origin;
                        int startP = 1;
                        for (int i = 0; i < ExtPileLst.Count; i++)
                        {

                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 194, 13), ref ex, "引桥桩基钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 359, 13), ref ex, "S4-11-3-11", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);


                            //TextPloter.AddPaperDBText(db,tKPointPile.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 161, 12.5), ref ex, dtProject.Rows[4][1].ToString(), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 366, 12.5), ref ex, dtProject.Rows[4][2].ToString(), 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);


                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 161, 12.5), ref ex, drPileRebar[0][2].ToString(), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 214, 12.5), ref ex, drPileRebar[0][6].ToString(), 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 242, 12.5), ref ex, drPileRebar[0][7].ToString(), 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 366, 12.5), ref ex, drPileRebar[0][3].ToString(), 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 33, 297 - 16.5), ref ex, (startP + index).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + 420 - 16.5, 297 - 16.5), ref ex, count.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y), ref ex, (startP + index).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPile.C3D(420 * i + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y), ref ex, count.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            PictureFrameTools.AddPaperDBText(db, tKPointPile, i, drawingConfigModel, ref ex, startP + index, count);

                            startP++;
                        }
                        #endregion

                        break;

                    case PierSubstructureType.PileCapRebar:
                        #region 绘制图形
                        OverAllScale = 8;
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;
                        List<Extents2d> ExtPileCapALst = new List<Extents2d>(), ExtPileCapBLst = new List<Extents2d>(), ExtPileCapPLst = new List<Extents2d>(), ExtPileCapDetailLst = new List<Extents2d>();
                        Extents2d ExtPileCapA, ExtPileCapB, ExtPileCapP, ExtPileCapDetail, extPileCapE;
                        Point2d RefPtPileCapA, RefPtPileCapB, RefPtPileCapP, RefPtPileCapDetail;
                        RefPtPileCapA = Point2d.Origin;
                        extPileCapE = new Extents2d(RefPtPileCapA, RefPtPileCapA);

                        List<PileCapRebarPara> pileCapRebarListGetone = new List<PileCapRebarPara>();
                        pileCapRebarListGetone.Add(pileCapRebarList[index]);
                        if (pileCapRebarList.Count > 0)
                        {
                            //for (int i = 0; i < pileRebarList.Count; i++)
                            for (int i = 0; i < dtPileCapDis.Rows.Count; i++)
                            {
                                List<PileCapRebarPara> pierDisList = pileCapRebarListGetone.FindAll(o => o.configure_name == dtPileCapDis.Rows[i]["configure_name"].ToString());
                                PileCapRebarPara pierPara = pileCapRebarListGetone.Find(o => o.configure_name == dtPileCapDis.Rows[i]["configure_name"].ToString());
                                try
                                {
                                    PileCapRebar pileRebar = new PileCapRebar(pierPara);
                                    if (ExtPileCapALst.Count > 0)
                                    {
                                        if (pierPara.width > pierPara.length)
                                        {
                                            RefPtPileCapA = RefPtPileCapA.C2D(extPileCapE.W() * 1.5, 0);
                                        }
                                        else
                                        {
                                            RefPtPileCapA = RefPtPileCapA.C2D(extPileCapE.W() * 1.2, 0);
                                        }
                                    }
                                    extPileCapE = new Extents2d(RefPtPileCapA, RefPtPileCapA);
                                    pileRebar.PlotElevationA(ref db, out ExtPileCapA, RefPtPileCapA, OverAllScale);
                                    ExtPileCapALst.Add(ExtPileCapA);
                                    if (pierPara.width > pierPara.length)
                                    {
                                        RefPtPileCapB = RefPtPileCapA.C2D(ExtPileCapA.W() + 50 * OverAllScale, 0);
                                        pileRebar.PlotElevationB(ref db, out ExtPileCapB, RefPtPileCapB, OverAllScale);
                                        ExtPileCapBLst.Add(ExtPileCapB);
                                    }
                                    else
                                    {
                                        RefPtPileCapB = RefPtPileCapA.C2D(ExtPileCapA.W() + 20 * OverAllScale, 0);
                                        pileRebar.PlotElevationB(ref db, out ExtPileCapB, RefPtPileCapB, OverAllScale);
                                        ExtPileCapBLst.Add(ExtPileCapB);
                                    }

                                    RefPtPileCapP = RefPtPileCapA.C2D(0, -ExtPileCapA.L() - 20 * OverAllScale);
                                    pileRebar.PlotElevationPlan(ref db, out ExtPileCapP, RefPtPileCapP, OverAllScale);
                                    ExtPileCapPLst.Add(ExtPileCapP);

                                    if (pierPara.width > pierPara.length)
                                    {
                                        RefPtPileCapDetail = RefPtPileCapP.C2D(ExtPileCapP.W() + 20 * OverAllScale, 0);
                                        pileRebar.RendeDetail(ref db, out ExtPileCapDetail, RefPtPileCapDetail, OverAllScale);
                                        ExtPileCapDetailLst.Add(ExtPileCapDetail);
                                    }
                                    else
                                    {
                                        RefPtPileCapDetail = RefPtPileCapP.C2D(ExtPileCapP.W() + 5 * OverAllScale, 0);
                                        pileRebar.RendeDetail(ref db, out ExtPileCapDetail, RefPtPileCapDetail, OverAllScale);
                                        ExtPileCapDetailLst.Add(ExtPileCapDetail);
                                    }

                                    extPileCapE = extPileCapE.Add(ExtPileCapA);
                                    extPileCapE = extPileCapE.Add(ExtPileCapDetail);

                                }
                                catch (Exception ex)
                                {

                                }
                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion

                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierSubPileCapLayout(db, "图纸", ExtPileCapALst, ExtPileCapBLst, ExtPileCapPLst, ExtPileCapDetailLst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                        Point2d tKPointPileCap = Point2d.Origin;
                        for (int i = 0; i < ExtPileCapALst.Count; i++)
                        {
                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 194, 13), ref ex, "引桥承台钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 359, 13), ref ex, "S4-11-3-9", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,tKPointPileCap.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y), ref ex, (i + 1 + index).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPointPileCap.C3D(420 * i + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y), ref ex, (count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            PictureFrameTools.AddPaperDBText(db, tKPointPileCap, i, drawingConfigModel, ref ex, i + 1 + index, count);
                        }
                        #endregion
                        break;

                    case PierSubstructureType.PierRebar:
                        #region 绘制图形
                        OverAllScale = 10;
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;
                        //OverAllScale = int.Parse(dtProject.Rows[2][3].ToString());
                        double extendscale = 5 / 6.0;
                        InitConfig.InitDimExtendStyle(Unit.Millimeter, Unit.Millimeter, OverAllScale, extendscale, "SRB.HT");
                        InitConfig.InitDimExtendStyle(Unit.Centimeter, Unit.Centimeter, OverAllScale, extendscale, "SRB.HT");
                        //List<Extents2d> ExtPierALst = new List<Extents2d>(), ExtPierBLst = new List<Extents2d>(), ExtPierCLst = new List<Extents2d>(), ExtPierDLst = new List<Extents2d>(), ExtPierNote1Lst = new List<Extents2d>(), ExtPierNote2Lst = new List<Extents2d>(),
                        //    ExtPierELst = new List<Extents2d>(), ExtPierFLst = new List<Extents2d>(), ExtPierGLst = new List<Extents2d>(), ExtPierHLst = new List<Extents2d>();
                        List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>> tuPage1Lst = new List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>>();
                        List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>> tuPage2Lst = new List<Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>>();
                        List<Tuple<Extents2d>> tuPage3Lst = new List<Tuple<Extents2d>>();
                        List<Tuple<Extents2d>> tuPage4Lst = new List<Tuple<Extents2d>>();
                        Extents2d ExtPierReA, ExtPierReB, ExtPierReC, ExtPierReD, ExtPierReE, ExtPierReF, ExtPierReG, ExtPierReBA, ExtPierReBB, ExtPierReBP, ExtPierReNote1, ExtPierReNote2;
                        Point2d RefPtPierReA, RefPtPierReB, RefPtPierReC, RefPtPierReD, RefPtPierReE, RefPtPierReF, RefPtPierReG, RefPtPierReBA, RefPtPierReBB, RefPtPierReBP, RefPtPierReNote1, RefPtPierReNote2;
                        RefPtPierReA = Point2d.Origin;
                        ExtPierReA = new Extents2d(RefPtPierReA, RefPtPierReA);
                        Extents2d ExtPierReS, ExtPierRebar;
                        Point2d RefPtPierReS, RefPtPierRebar;
                        Extents2d Ext = new Extents2d(RefPtPierReA, RefPtPierReA);
                        if (pierList.Count > 0)
                        {
                            double H = 0;
                            //List<PierPara> pierDisList = pierList;
                            List<PierPara> pierDisList = pierList.FindAll(o => o.name == dtPDis.Rows[index]["name"].ToString());
                            PierPara pierPara = pierList.Find(o => o.name == dtPDis.Rows[index]["name"].ToString());
                            try
                            {
                                PierRebar pierRebar = new PierRebar(pierPara, extendscale);
                                #region  第一页
                                List<Extents2d> lst = new List<Extents2d>();
                                if (tuPage1Lst.Count > 0)
                                    RefPtPierReA = RefPtPierReA.C2D(0, -Ext.L() * 1.5);
                                Ext = new Extents2d(RefPtPierReA, RefPtPierReA);
                                ExtPierReA = new Extents2d(RefPtPierReA, RefPtPierReA);
                                pierRebar.PlotPierelEvationA(ref db, out ExtPierReA, RefPtPierReA, OverAllScale);
                                lst.Add(ExtPierReA);
                                Ext = Ext.Add(ExtPierReA);

                                RefPtPierReC = RefPtPierReA.C2D(ExtPierReA.W() + 20 * OverAllScale, 0);
                                pierRebar.PlotPierSideB(ref db, out ExtPierReC, RefPtPierReC, OverAllScale);
                                lst.Add(ExtPierReC);
                                Ext = Ext.Add(ExtPierReC);

                                RefPtPierReE = RefPtPierReC.C2D(ExtPierReA.W() + 20 * OverAllScale);
                                pierRebar.PlotSectionEE(ref db, out ExtPierReE, RefPtPierReE, OverAllScale);
                                lst.Add(ExtPierReE);

                                RefPtPierReF = RefPtPierReC.C2D(ExtPierReA.W() + 20 * OverAllScale, -ExtPierReE.L() - 8 * OverAllScale);
                                pierRebar.PlotSectionFF(ref db, out ExtPierReF, RefPtPierReF, OverAllScale);
                                lst.Add(ExtPierReF);

                                RefPtPierReG = RefPtPierReF.C2D(0, -ExtPierReF.L() - 8 * OverAllScale);
                                pierRebar.PlotSectionGG(ref db, out ExtPierReG, RefPtPierReG, OverAllScale);
                                lst.Add(ExtPierReG);

                                //RefPtPierReNote1 = RefPtPierReG.C2D(-ExtPierReG.W() * 0.5, -ExtPierReG.L() - 5 * OverAllScale);
                                //pierRebar.PlotPierNote(ref db, out ExtPierReNote1, RefPtPierReNote1, OverAllScale);
                                //lst.Add(ExtPierReNote1);

                                Ext = Ext.Add(ExtPierReG);

                                Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d> tuPage1 = new Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>(ExtPierReA, ExtPierReC, ExtPierReE, ExtPierReF, ExtPierReG);
                                tuPage1Lst.Add(tuPage1);
                                #endregion

                                #region  第二页
                                lst = new List<Extents2d>();
                                RefPtPierReB = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);

                                ExtPierReB = new Extents2d(RefPtPierReB, RefPtPierReB);
                                pierRebar.PlotPierelEvationC(ref db, out ExtPierReB, RefPtPierReB, OverAllScale);
                                lst.Add(ExtPierReB);
                                Ext = Ext.Add(ExtPierReB);

                                RefPtPierReD = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, 0);
                                pierRebar.PlotPierSideD(ref db, out ExtPierReD, RefPtPierReD, OverAllScale);
                                lst.Add(ExtPierReD);
                                Ext = Ext.Add(ExtPierReD);

                                RefPtPierReBA = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, 0);
                                pierRebar.PlotPierBlockA(ref db, out ExtPierReBA, RefPtPierReBA, OverAllScale);
                                lst.Add(ExtPierReBA);

                                RefPtPierReBB = RefPtPierReA.C2D(Ext.W() + 20 * OverAllScale, -ExtPierReBA.L() - 15 * OverAllScale);
                                pierRebar.PlotPierBlockB(ref db, out ExtPierReBB, RefPtPierReBB, OverAllScale);
                                lst.Add(ExtPierReBB);

                                RefPtPierReBP = RefPtPierReBB.C2D(0, -ExtPierReBB.L() - 15 * OverAllScale);
                                pierRebar.PlotPierBlockPlan(ref db, out ExtPierReBP, RefPtPierReBP, OverAllScale);
                                lst.Add(ExtPierReBP);

                                RefPtPierReNote2 = RefPtPierReBP.C2D(-ExtPierReBP.W() * 0.5, -ExtPierReBP.L() - 10 * OverAllScale);
                                //RefPtPierReNote2 = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, -ExtPierReBP.L() - 10 * OverAllScale);
                                pierRebar.PlotPierNote(ref db, out ExtPierReNote2, RefPtPierReNote2, pierDisList, OverAllScale);
                                lst.Add(ExtPierReNote2);
                                Ext = Ext.Add(ExtPierReNote2);
                                Ext = Ext.Add(ExtPierReBP);
                                Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d> tuPage2 = new Tuple<Extents2d, Extents2d, Extents2d, Extents2d, Extents2d, Extents2d>(ExtPierReB, ExtPierReD, ExtPierReBB, ExtPierReBA, ExtPierReBP, ExtPierReNote2);
                                tuPage2Lst.Add(tuPage2);
                                #endregion

                                #region  第三页
                                lst = new List<Extents2d>();
                                RefPtPierReS = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);
                                pierRebar.PlotPierSample(ref db, out ExtPierReS, RefPtPierReS, OverAllScale);
                                lst.Add(ExtPierReS);
                                Ext = Ext.Add(ExtPierReS);
                                Tuple<Extents2d> tuPage3 = new Tuple<Extents2d>(ExtPierReS);
                                tuPage3Lst.Add(tuPage3);
                                #endregion

                                #region  第四页
                                lst = new List<Extents2d>();
                                RefPtPierRebar = RefPtPierReA.C2D(Ext.W() + 50 * OverAllScale, 0);
                                pierRebar.PlotPierRebarTable(ref db, out ExtPierRebar, RefPtPierRebar, OverAllScale, pierDisList);
                                lst.Add(ExtPierRebar);
                                Ext = Ext.Add(ExtPierRebar);
                                Tuple<Extents2d> tuPage4 = new Tuple<Extents2d>(ExtPierRebar);
                                tuPage4Lst.Add(tuPage4);
                                #endregion
                            }
                            catch (Exception ex)
                            {

                            }
                        }

                        #endregion

                        #region 模型空间到布局空间投影处理
                        int pdfnum = 4;
                        LayoutTools.CreatePierSubPierLayout(db, "图纸", tuPage1Lst, tuPage2Lst, tuPage3Lst, tuPage4Lst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale, extendscale);
                        Point2d tKPointPier = Point2d.Origin;
                        for (int i = 0; i < tuPage1Lst.Count; i++)
                        {
                            for (int j = 0; j < pdfnum; j++)
                            {
                                Extents2d ex = new Extents2d();
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 194, 13 - 297 * i), ref ex, "引桥墩身钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 245, 13 - 297 * i), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 281, 13 - 297 * i), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 315, 13 - 297 * i), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 359, 13 - 297 * i), ref ex, "S4-11-3-8", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db,tKPointPier.C3D(420 * j + 400.5, 13 - 297 * i), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y - 297 * i), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y - 297 * i), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y - 297 * i), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y - 297 * i), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y - 297 * i), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y - 297 * i), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y - 297 * i), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);

                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y - 297 * i), ref ex, (pdfnum * index + j + 1).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                //TextPloter.AddPaperDBText(db, tKPointPier.C3D(420 * j + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y - 297 * i), ref ex, (tuPage1Lst.Count * pdfnum * count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                                PictureFrameTools.AddPaperDBText(db, tKPointPier, j, drawingConfigModel, ref ex, pdfnum * index + j + 1, tuPage1Lst.Count * pdfnum * count);
                            }
                        }
                        #endregion
                        break;

                    case PierSubstructureType.BeamRebar:
                        #region 绘制图形
                        OverAllScale = 8;
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;

                        List<Extents2d> ExtBeamLst = new List<Extents2d>(), ExtBeamALst = new List<Extents2d>(), ExtBeamDetailLst = new List<Extents2d>();
                        Extents2d ExtBeam, ExtBeamA, ExtBeamDetail, ExtBRebar;
                        Point2d RefPtBeam, RefPtBeamA, RefPtBeamDetail;
                        Point2d ptOrigin = Point2d.Origin;
                        RefPtBeam = Point2d.Origin;
                        ExtBeam = new Extents2d(RefPtBeam, RefPtBeam);
                        ExtBRebar = new Extents2d(RefPtBeam, RefPtBeam);
                        List<PierBeamRebarPara> beamRebarListGetone = new List<PierBeamRebarPara>();
                        beamRebarListGetone.Add(beamRebarList[index]);
                        if (pierList.Count > 0)
                        {
                            double H = 0;
                            //List<PierPara> pierDisList = pierList;
                            List<PierPara> pierDisList = pierList.FindAll(o => o.name == dtPDis.Rows[index]["name"].ToString());
                            PierPara pierPara = pierList.Find(o => o.name == dtPDis.Rows[index]["name"].ToString());
                            try
                            {
                                PierBeamRebar beamRebar = new PierBeamRebar(pierPara, beamRebarListGetone[0]);
                                if (ExtBeamLst.Count > 0)
                                    RefPtBeam = ptOrigin.C2D(ExtBRebar.W() + 50 * OverAllScale, 0);
                                extPileCapE = new Extents2d(RefPtBeam, RefPtBeam);
                                beamRebar.PlotElevation(ref db, out ExtBeam, RefPtBeam, OverAllScale);
                                ExtBeamLst.Add(ExtBeam);
                                ExtBRebar = ExtBRebar.Add(ExtBeam);

                                RefPtBeamA = RefPtBeam.C2D(ExtBeam.W() + 20 * OverAllScale, 0);
                                beamRebar.PlotElevationA(ref db, out ExtBeamA, RefPtBeamA, OverAllScale);
                                ExtBeamALst.Add(ExtBeamA);
                                ExtBRebar = ExtBRebar.Add(ExtBeamA);


                                RefPtBeamDetail = RefPtBeamA.C2D(ExtBeamA.W() + 20 * OverAllScale, 0);
                                beamRebar.RendeDetail(ref db, out ExtBeamDetail, RefPtBeamDetail, OverAllScale);
                                ExtBeamDetailLst.Add(ExtBeamDetail);
                                ExtBRebar = ExtBRebar.Add(ExtBeamDetail);
                                /**
                                if (dtProject.Rows[0][0].ToString() != "澜沧江")
                                {
                                    PierBeamRebar beamRebar = new PierBeamRebar(pierPara, beamRebarListGetone[0]);
                                    if (ExtBeamLst.Count > 0)
                                        RefPtBeam = ptOrigin.C2D(ExtBRebar.W() + 50 * OverAllScale, 0);
                                    extPileCapE = new Extents2d(RefPtBeam, RefPtBeam);
                                    beamRebar.PlotElevation(ref db, out ExtBeam, RefPtBeam, OverAllScale);
                                    ExtBeamLst.Add(ExtBeam);
                                    ExtBRebar = ExtBRebar.Add(ExtBeam);

                                    RefPtBeamA = RefPtBeam.C2D(ExtBeam.W() + 20 * OverAllScale, 0);
                                    beamRebar.PlotElevationA(ref db, out ExtBeamA, RefPtBeamA, OverAllScale);
                                    ExtBeamALst.Add(ExtBeamA);
                                    ExtBRebar = ExtBRebar.Add(ExtBeamA);


                                    RefPtBeamDetail = RefPtBeamA.C2D(ExtBeamA.W() + 20 * OverAllScale, 0);
                                    beamRebar.RendeDetail(ref db, out ExtBeamDetail, RefPtBeamDetail, OverAllScale);
                                    ExtBeamDetailLst.Add(ExtBeamDetail);
                                    ExtBRebar = ExtBRebar.Add(ExtBeamDetail);
                                }
                                else
                                {
                                    PierBeamRebarLCJ beamRebar = new PierBeamRebarLCJ(pierPara, beamRebarListGetone[0]);
                                    if (ExtBeamLst.Count > 0)
                                        RefPtBeam = ptOrigin.C2D(ExtBRebar.W() + 50 * OverAllScale, 0);
                                    extPileCapE = new Extents2d(RefPtBeam, RefPtBeam);
                                    beamRebar.PlotElevation(ref db, out ExtBeam, RefPtBeam, OverAllScale);
                                    ExtBeamLst.Add(ExtBeam);
                                    ExtBRebar = ExtBRebar.Add(ExtBeam);

                                    RefPtBeamA = RefPtBeam.C2D(ExtBeam.W() + 20 * OverAllScale, 0);
                                    beamRebar.PlotElevationA(ref db, out ExtBeamA, RefPtBeamA, OverAllScale);
                                    ExtBeamALst.Add(ExtBeamA);
                                    ExtBRebar = ExtBRebar.Add(ExtBeamA);


                                    RefPtBeamDetail = RefPtBeamA.C2D(ExtBeamA.W() + 20 * OverAllScale, 0);
                                    beamRebar.RendeDetail(ref db, out ExtBeamDetail, RefPtBeamDetail, OverAllScale);
                                    ExtBeamDetailLst.Add(ExtBeamDetail);
                                    ExtBRebar = ExtBRebar.Add(ExtBeamDetail);
                                }
                                **/


                                //extPileCapE = extPileCapE.Add(ExtPileCapA);
                                //extPileCapE = extPileCapE.Add(ExtPileCapDetail);

                            }
                            catch (Exception ex)
                            {

                            }
                        }


                        //RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2, OverAllScale);
                        #endregion
                        #region 模型空间到布局空间投影处理

                        LayoutTools.CreatePierBeamLayout(db, "图纸", ExtBeamLst, ExtBeamALst, ExtBeamDetailLst, Extensions.leftWidth, Extensions.rightWidth, Extensions.bottomHeight, Extensions.topHeight, OverAllScale, ExtBeamLst.Count, 0);
                        tKPoint = Point2d.Origin;
                        for (int i = 0; i < ExtBeamLst.Count; i++)
                        {
                            Extents2d ex = new Extents2d();

                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y), ref ex, (i + 1 + index).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, tKPoint.C3D(420 * i + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y), ref ex, (count).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            PictureFrameTools.AddPaperDBText(db, tKPoint, i, drawingConfigModel, ref ex, i + 1 +index, count);

                        }
                        #endregion
                        break;

                    case PierSubstructureType.AbutmentPileRebar:
                        #region 绘制图形
                        OverAllScale = 5;
                        drawingConfigModel = PictureFrameTools.GetDrawingConfig(dtProject, catalogid, dtProjectConfig);
                        OverAllScale = drawingConfigModel.drawing_scale;
                        List<Extents2d> AbutmentAbutmentExtPileLst = new List<Extents2d>(), AbutmentAbutmentExtLPileLst = new List<Extents2d>(), AbutmentAbutmentExtCPileLst = new List<Extents2d>(), AbutmentAbutmentExtDetailLst = new List<Extents2d>();
                        Extents2d AbutmentExtPile, AbutmentExtLPile, AbutmentExtCPile, AbutmentExtDetail, AbutmentextE;
                        Point2d AbutmentRefPtPile, AbutmentRefPtLPile, AbutmentRefPtCPile, AbutmentRefPtDetail;
                        AbutmentRefPtPile = Point2d.Origin;
                        AbutmentextE = new Extents2d(AbutmentRefPtPile, AbutmentRefPtPile);
                        List<PileRebarPara> AbutmentpileRebarListGetone = new List<PileRebarPara>();

                        if (AbutmentpileRebarList.Count > 0)
                        {
                            AbutmentpileRebarListGetone.Add(AbutmentpileRebarList[index]);
                            //for (int i = 0; i < pileRebarList.Count; i++)
                            List<PileRebarPara> pierDisList = AbutmentpileRebarListGetone;
                            PileRebarPara pierPara = AbutmentpileRebarListGetone[0];
                            try
                            {
                                PileRebar pileRebar = new PileRebar(pierPara, _bridgeId, isExistCap);
                                if (AbutmentAbutmentExtPileLst.Count > 0)
                                    AbutmentRefPtPile = AbutmentRefPtPile.C2D(AbutmentextE.W() * 1.2, 0);
                                AbutmentextE = new Extents2d(AbutmentRefPtPile, AbutmentRefPtPile);
                                pileRebar.PlotPile(ref db, out AbutmentExtPile, AbutmentRefPtPile, OverAllScale);
                                AbutmentAbutmentExtPileLst.Add(AbutmentExtPile);
                                AbutmentRefPtLPile = AbutmentRefPtPile.C2D(AbutmentExtPile.W() + 20 * OverAllScale, -AbutmentExtPile.L() + AbutmentpileRebarListGetone[0].bottom_distance + 15 * OverAllScale);
                                if (pierPara.is_out_double_layout)
                                {
                                    AbutmentRefPtPile.C2D(AbutmentExtPile.W() + 5 * OverAllScale, -AbutmentExtPile.L() + AbutmentpileRebarListGetone[0].bottom_distance + 15 * OverAllScale);
                                }
                                pileRebar.PlotPileSpiral(ref db, out AbutmentExtLPile, AbutmentRefPtLPile, OverAllScale);
                                AbutmentAbutmentExtLPileLst.Add(AbutmentExtLPile);

                                AbutmentRefPtCPile = AbutmentRefPtPile.C2D(AbutmentExtPile.W() + 20 * OverAllScale, 0);
                                pileRebar.PlotCPile(ref db, out AbutmentExtCPile, AbutmentRefPtCPile, OverAllScale);
                                AbutmentAbutmentExtCPileLst.Add(AbutmentExtCPile);

                                AbutmentRefPtDetail = AbutmentRefPtCPile.C2D(AbutmentExtLPile.W() + 5 * OverAllScale, -AbutmentExtCPile.L() - 3 * OverAllScale);
                                pileRebar.RendeDetail(ref db, AbutmentRefPtDetail, out AbutmentExtDetail, pierDisList, OverAllScale);
                                AbutmentAbutmentExtDetailLst.Add(AbutmentExtDetail);

                                AbutmentextE = AbutmentextE.Add(AbutmentExtCPile);
                                AbutmentextE = AbutmentextE.Add(AbutmentExtDetail);

                            }
                            catch (Exception ex)
                            {

                            }
                        }


                        //RendeDetail(ref db, AbutmentRefPtDetail, out AbutmentExtDetail, dt1, dt2, OverAllScale);
                        #endregion


                        #region 模型空间到布局空间投影处理
                        LayoutTools.CreatePierSubPileLayout(db, "图纸", AbutmentAbutmentExtPileLst, AbutmentAbutmentExtLPileLst, AbutmentAbutmentExtCPileLst, AbutmentAbutmentExtDetailLst, Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                        Point2d AbutmenttKPointPile = Point2d.Origin;
                        int startA = 1;
                        for (int i = 0; i < AbutmentAbutmentExtPileLst.Count; i++)
                        {

                            Extents2d ex = new Extents2d();
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 194, 13), ref ex, "引桥桩基钢筋构造", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 245, 13), ref ex, "设计1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 281, 13), ref ex, "复核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 315, 13), ref ex, "审核1", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 359, 13), ref ex, "S4-11-3-11", 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 400.5, 13), ref ex, System.DateTime.Now.ToString("yyyy年MM月"), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);


                            //TextPloter.AddPaperDBText(db,AbutmenttKPointPile.C3D(420 * i + 400, 12.5), ref ex, System.DateTime.Now.ToString("yyyy.MM"), 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_drawingname_x, drawingConfigModel.font_location_drawingname_y), ref ex, drawingConfigModel.name, 1, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_designer_x, drawingConfigModel.font_location_designer_y), ref ex, drawingConfigModel.designer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_reviewer_x, drawingConfigModel.font_location_reviewer_y), ref ex, drawingConfigModel.reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_first_reviewer_x, drawingConfigModel.font_location_first_reviewer_y), ref ex, drawingConfigModel.first_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_second_reviewer_x, drawingConfigModel.font_location_second_reviewer_y), ref ex, drawingConfigModel.second_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_third_reviewer_x, drawingConfigModel.font_location_third_reviewer_y), ref ex, drawingConfigModel.third_reviewer, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_drawing_no_x, drawingConfigModel.font_location_drawing_no_y), ref ex, drawingConfigModel.drawing_no, 0.85, 4.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_page_x, drawingConfigModel.font_location_page_y), ref ex, (startA + index).ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            //TextPloter.AddPaperDBText(db, AbutmenttKPointPile.C3D(420 * i + drawingConfigModel.font_location_page_sum_x, drawingConfigModel.font_location_page_sum_y), ref ex, count.ToString(), 1, 3.5, "SRB.HT", 0, TextHorizontalMode.TextCenter);
                            PictureFrameTools.AddPaperDBText(db, AbutmenttKPointPile, i, drawingConfigModel, ref ex, startA+ index, count);

                            startA++;

                        }
                        #endregion
                        break;
                }
            }
            catch (Exception ex)
            {

            }
            dtProjectConfigTb = dtProjectConfig;
            return Flag;
        }
        public string FinddictItem(string sql, string value)
        {
            System.Data.DataTable dt = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
            System.Data.DataRow[] dr = dt.Select("item_value='" + value + "'");
            string result = "";
            if (dr.Length > 0)
            {
                result = dr[0]["item_text"].ToString();
            }
            else
            {
                result = value;
            }
            return result;
        }
    }


}
